artiq-extrapkg/flake.nix

164 lines
5.5 KiB
Nix
Raw Normal View History

2022-02-12 17:10:14 +08:00
{
description = "Additional packages for ARTIQ";
inputs.artiq.url = git+https://github.com/m-labs/artiq.git;
outputs = { self, artiq }:
let
pkgs = import artiq.inputs.nixpkgs { system = "x86_64-linux"; };
condaDeps = with pkgs; [ zlib xorg.libSM xorg.libICE xorg.libX11 xorg.libXau xorg.libXi xorg.libXrender libselinux libGL ];
# Use the full Anaconda distribution, which already contains conda-build and its many dependencies.
condaInstaller = pkgs.fetchurl {
url = "https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh";
sha256 = "sha256-/t+eNAA5VX97XoqKhq/6nSmfXpggFEvXuSrp9+4IrGA=";
};
condaInstallerEnv = pkgs.buildFHSUserEnv {
name = "conda-installer-env";
targetPkgs = pkgs: condaDeps;
};
condaInstalled = pkgs.stdenvNoCC.mkDerivation {
name = "conda-installed";
src = condaInstaller;
buildInputs = [ condaInstallerEnv ];
phases = [ "buildPhase" "installPhase" ];
buildPhase =
''
cp $src conda-installer.sh
chmod +x 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/ conda-installer.sh
'';
installPhase =
''
conda-installer-env -c "./conda-installer.sh -p $out -b"
substituteInPlace $out/lib/python3.9/site-packages/conda/gateways/disk/__init__.py \
--replace "os.chmod(path, 0o2775)" "pass"
'';
};
condaBuilderEnv = pkgs.buildFHSUserEnv {
name = "conda-builder-env";
targetPkgs = pkgs: condaDeps ++ [ condaInstalled ];
};
2022-02-12 17:43:12 +08:00
makeCondaRecipe = (constituent:
''
# conda build breaks if write permissions aren't set on source files.
cp --no-preserve=mode,ownership -R ${constituent.src} workaround-conda
cd workaround-conda
tar cf ../${constituent.name}.tar .
cd ..
rm -rf workaround-conda
mkdir -p conda/${constituent.name}
cat << EOF > conda/${constituent.name}/meta.yaml
package:
name: ${constituent.name}
version: ${constituent.version}
source:
url: ../../${constituent.name}.tar
{% set data = load_setup_py_data() %}
build:
noarch: python
entry_points:
# NOTE: conda-build cannot distinguish between console and gui scripts
{% for entry_point_type, entry_points in data.get("entry_points", dict()).items() -%}
{% for entry_point in entry_points -%}
- {{ entry_point }}
{% endfor %}
{% endfor %}
ignore_prefix_files: True
requirements:
run:
${pkgs.lib.concatStringsSep "\n" (map (s: " - ${s}") constituent.dependencies)}
EOF
cat << EOF > conda/${constituent.name}/build.sh
#!/bin/bash
set -e
2022-02-12 17:46:34 +08:00
${constituent.preSetup or ""}
2022-02-12 17:43:12 +08:00
python setup.py install \
--prefix=\$PREFIX \
--single-version-externally-managed \
--record=record.txt \
--no-compile
EOF
chmod 755 conda/${constituent.name}/build.sh
''
);
makeCondaChannel = constituents: pkgs.stdenvNoCC.mkDerivation {
name = "conda-channel";
buildInputs = [ condaBuilderEnv ];
phases = [ "buildPhase" "installPhase" ];
buildPhase = pkgs.lib.concatStringsSep "\n" (map makeCondaRecipe constituents);
installPhase =
''
HOME=`pwd`
mkdir $out
conda-builder-env -c "
${pkgs.lib.concatStringsSep "\n"
(map (constituent: "conda build --no-anaconda-upload --no-test --output-folder $out conda/${constituent.name}") constituents)}
"
mkdir $out/nix-support
for package in $out/*/*.tar.bz2; do
echo file conda $package >> $out/nix-support/hydra-build-products
done
'';
};
2022-02-12 17:10:14 +08:00
in rec {
packages.x86_64-linux = {
2022-02-12 17:43:12 +08:00
condaChannel = makeCondaChannel [
{
name = "sipyco";
version = artiq.inputs.sipyco.packages.x86_64-linux.sipyco.version;
src = artiq.inputs.sipyco.packages.x86_64-linux.sipyco.src;
dependencies = [ "numpy" "pybase64" ];
}
{
name = "pythonparser";
version = artiq.packages.x86_64-linux.pythonparser.version;
src = artiq.packages.x86_64-linux.pythonparser.src;
dependencies = [ "regex" ];
}
2022-02-12 17:43:12 +08:00
{
name = "artiq";
version = artiq.packages.x86_64-linux.artiq.version;
src = artiq.packages.x86_64-linux.artiq.src;
2022-02-12 17:46:34 +08:00
preSetup =
''
export VERSIONEER_OVERRIDE=${artiq.packages.x86_64-linux.artiq.version}
export VERSIONEER_REV=${artiq.sourceInfo.rev}
'';
2022-02-12 17:43:12 +08:00
dependencies = [
"pythonparser"
"scipy"
"numpy"
"prettytable"
"h5py"
"python-dateutil"
"pyqt"
"qasync"
"pyqtgraph"
"pygit2"
"python-levenshtein"
"sipyco"
"llvmlite"
"llvm-tools"
"lld"
];
}
];
2022-02-12 17:10:14 +08:00
};
hydraJobs = {
2022-02-12 17:43:12 +08:00
inherit (packages.x86_64-linux) condaChannel;
2022-02-12 17:10:14 +08:00
};
};
}