2019-02-14 15:29:42 +08:00
|
|
|
# We need to pass the whole source to conda for the git variables to work.
|
|
|
|
# recipe must be a string pointing to a path within the source.
|
|
|
|
|
2019-02-15 18:17:34 +08:00
|
|
|
{ pkgs }:
|
2019-04-19 19:52:34 +08:00
|
|
|
{ name, src, recipe ? "fake-conda"}:
|
2019-02-14 15:29:42 +08:00
|
|
|
|
|
|
|
with pkgs;
|
|
|
|
|
|
|
|
let
|
|
|
|
condaDeps = [ stdenv.cc xorg.libSM xorg.libICE xorg.libXrender libselinux ];
|
|
|
|
# Use the full Anaconda distribution, which already contains conda-build and its many dependencies,
|
|
|
|
# so we don't have to manually deal with them.
|
|
|
|
condaInstaller = fetchurl {
|
2019-07-05 10:09:03 +08:00
|
|
|
url = "https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh";
|
|
|
|
sha256 = "0fmpdd5876ylds98mydmv5klnwlzasa461k0l1f4vhbw96vm3j25";
|
2019-02-14 15:29:42 +08:00
|
|
|
};
|
|
|
|
condaSrcChmod = runCommand "conda-src-chmod" { } "mkdir $out; cp ${condaInstaller} $out/conda-installer.sh; chmod +x $out/conda-installer.sh";
|
|
|
|
condaInstallerEnv = buildFHSUserEnv {
|
|
|
|
name = "conda-installer-env";
|
|
|
|
targetPkgs = pkgs: ([ condaSrcChmod ] ++ condaDeps);
|
|
|
|
};
|
|
|
|
|
|
|
|
condaInstalled = runCommand "conda-installed" { }
|
|
|
|
''
|
|
|
|
${condaInstallerEnv}/bin/conda-installer-env -c "${condaSrcChmod}/conda-installer.sh -p $out -b"
|
2019-07-05 10:09:03 +08:00
|
|
|
substituteInPlace $out/lib/python3.7/site-packages/conda/gateways/disk/__init__.py \
|
|
|
|
--replace "os.chmod(path, 0o2775)" "pass"
|
2019-02-14 15:29:42 +08:00
|
|
|
'';
|
|
|
|
condaBuilderEnv = buildFHSUserEnv {
|
|
|
|
name = "conda-builder-env";
|
|
|
|
targetPkgs = pkgs: [ condaInstalled ] ++ condaDeps;
|
|
|
|
};
|
|
|
|
|
|
|
|
in stdenv.mkDerivation {
|
|
|
|
inherit name src;
|
|
|
|
buildInputs = [ condaBuilderEnv ];
|
|
|
|
buildCommand =
|
|
|
|
''
|
|
|
|
HOME=`pwd`
|
|
|
|
mkdir $out
|
2019-02-15 17:23:54 +08:00
|
|
|
${condaBuilderEnv}/bin/conda-builder-env -c "PYTHON=python conda build --no-anaconda-upload --no-test --output-folder $out $src/${recipe}"
|
2019-02-14 15:29:42 +08:00
|
|
|
|
|
|
|
mkdir -p $out/nix-support
|
|
|
|
echo file conda $out/noarch/*.tar.bz2 >> $out/nix-support/hydra-build-products
|
|
|
|
'';
|
|
|
|
}
|