Two topics related to making use of nix easier in the lab.
1) Be able to freeze ARTIQ+Sinara and dependencies so we can rely on
a particular release for production lab work. This would include being
able to build gateware-firmware on that version. Presently it looks
like I need to specify both a commit of artiq and nix-scripts. It would be
convenient to have official release tags with broader scope (ARTIQ+Sinara).
2) Be able to edit artiq dependencies and make accessible accessible from
within a running nix environment. M-Labs tip on the development page
provides info on how to do this for artiq-fast/shell-dev.nix using
"artiqSrc = <artiqSrc>;" We confirm that this works. However, the
"blessed" approach for end users to run artiq involves using
artiq-full.artiq but there's no "artiqSrc = <artiqSrc>;"
A student on my group is looking into using nix flakes to address both these topics.
{
description = "artiq-full development enviroment with custom artiq source";
/* Use the following command to install flake: "nix-env -iA nixpkgs.nixFlakes". Then add
"experimental-features = nix-command flakes" to "~/.config/nix/nix.conf" or
"/etc/nix/nix.conf". You have to create either file, assuming you haven't already. */
/* To setup your environment install flakes, clone artiq source, set the directory of in
this file, run "nix flake check", followed by "nix develop" in the same directory of this
file. Fair warning will the last command will take 1-2 hours to run on the first setup,
but after that it is nearly instant. "nix develop" replaces the old nix-shell. */
/* Note the shell.nix file is not needed anymore and has been move to the bottom of this
file. It has been copy and pasted into devShell, so don't forget addex any other packages
you may need. */
/* This build works but you can grab the latest build from
"https://nixbld.m-labs.hk/jobset/artiq/full#tabs-evaluations". Click the latest successful
evaluation umber, then scroll down and click artiq-full. Copy the link under build products.
*/
inputs.nixScripts= {
url = "https://nixbld.m-labs.hk/build/130766/download/1/nixexprs.tar.xz";
flake = false;
};
# Directory to your artiq source; no relative paths. Can be set to github if you prefer.
inputs.artiqSrc = {
url = "/home/rgresia/experiment/artiq";
flake = false;
};
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, nixScripts, flake-utils, artiqSrc }:
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
let
generatedNix = builtins.fetchTarball {
url = lock.nodes.nixScripts.locked.url;
sha256 = lock.nodes.nixScripts.locked.narHash;
};
in
flake-utils.lib.eachSystem["x86_64-linux"]
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
artiq-src = pkgs.runCommand "artiq-src" { buildInputs = [ pkgs.rsync ]; }
''
mkdir $out
mkdir $out/fast
mkdir $out/fast/pkgs
mkdir $out/board-generated
rsync -a --exclude=fast --exclude=board-generated ${generatedNix}/* $out
rsync -a --exclude=pkgs ${generatedNix}/fast/* $out/fast
rsync -a --exclude=artiq-src.nix ${generatedNix}/fast/pkgs/* $out/fast/pkgs
cp -r ${generatedNix}/board-generated/* $out/board-generated
cat > $out/fast/pkgs/artiq-src.nix << EOF
{ fetchgit }: ${lock.nodes.artiqSrc.locked.path}
EOF
'';
in
{
devShell =
let artiq-full = import artiq-src { inherit pkgs; }; in
pkgs.mkShell {
buildInputs = [
(pkgs.python3.withPackages(ps: [
artiq-full.artiq
artiq-full.artiq-comtools
artiq-full.wand
artiq-full.lda
artiq-full.korad_ka3005p
artiq-full.novatech409b
artiq-full.thorlabs_tcube
]))
];
shellHook =
''
export PYTHONPATH=${lock.nodes.artiqSrc.locked.path}
'';
};
}
);
}