nix-scripts/artiq-fast/conda/builder-env.nix

55 lines
2.1 KiB
Nix
Raw Permalink Normal View History

2019-07-17 23:50:06 +08:00
{ pkgs }:
with pkgs;
let
2021-07-05 15:21:53 +08:00
condaDeps = [ stdenv.cc zlib xorg.libSM xorg.libICE xorg.libX11 xorg.libXau xorg.libXi xorg.libXrender libselinux libGL ];
2019-07-17 23:50:06 +08:00
# 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 {
2021-07-05 15:21:53 +08:00
url = "https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh";
sha256 = "0lrxwd3pwz8k3jxwgkd9x47wgkqqy9s8m7hgx1x2gw4gcwysnl97";
2019-07-17 23:50:06 +08:00
};
2021-07-05 15:21:53 +08:00
condaSrcChmod = runCommand "conda-src-chmod" { }
''
mkdir $out
cp ${condaInstaller} $out/conda-installer.sh
chmod +x $out/conda-installer.sh
# keep the same file length to avoid breaking embedded payload offsets
sed -i 0,/unset\ LD_LIBRARY_PATH/s//\#nset\ LD_LIBRARY_PATH/ $out/conda-installer.sh
'';
2019-07-17 23:50:06 +08:00
condaInstallerEnv = buildFHSUserEnv {
name = "conda-installer-env";
targetPkgs = pkgs: ([ condaSrcChmod ] ++ condaDeps);
};
2020-06-09 18:21:54 +08:00
# for binutils
2020-06-09 17:29:38 +08:00
libiconv-filename = "libiconv-1.15-h516909a_1006.tar.bz2";
libiconv = pkgs.fetchurl {
url = "https://anaconda.org/conda-forge/libiconv/1.15/download/linux-64/${libiconv-filename}";
sha256 = "1y1g807881j95f9s6mjinf6b7mqa51vc9jf0v7cx8hn7xx4d10ik";
};
2019-07-17 23:50:06 +08:00
condaInstalled = runCommand "conda-installed" { }
''
${condaInstallerEnv}/bin/conda-installer-env -c "${condaSrcChmod}/conda-installer.sh -p $out -b"
2021-07-05 15:21:53 +08:00
substituteInPlace $out/lib/python3.8/site-packages/conda/gateways/disk/__init__.py \
2019-07-17 23:50:06 +08:00
--replace "os.chmod(path, 0o2775)" "pass"
2020-06-09 17:29:38 +08:00
# The conda garbage breaks if the package filename is prefixed with the Nix store hash.
# Symptom is "WARNING conda.core.prefix_data:_load_single_record(167): Ignoring malformed
# prefix record at: /nix/store/[...].json", and the package is not registered in the conda
# list, even though its files are installed.
ln -s ${libiconv} ${libiconv-filename}
${condaInstallerEnv}/bin/conda-installer-env -c "$out/bin/conda install ${libiconv-filename}"
2019-07-17 23:50:06 +08:00
'';
in
buildFHSUserEnv {
name = "conda-builder-env";
2020-06-09 18:21:54 +08:00
targetPkgs = pkgs: ([ condaInstalled ] ++ condaDeps ++ [
# for llvm-or1k
cmake
]
);
2019-07-17 23:50:06 +08:00
}