• Asking for help
  • nix-shell error "attribute 'rustLib' missing" after fresh ARTIQ install

After I install ARTIQ, I get the following error message when I issue the nix-shell command:

$ nix-shell artiq.nix
error: attribute 'rustLib' missing, at /nix/store/f2rxgz23bmmy55byl71v9zgmkkmd59ac-artiq-full/artiq-full/fast/rust-platform.nix:9:6
(use '--show-trace' to show detailed location information)

Note: workaround found (see workaround number 4 below). It appears that something was broken in the artiq-full beta channel.

Below is a step-by-step description of the installation producedure that I am using.

This exact same installation procedure was working without any error message on 30 August 2021.

Start a Linux instance on AWS (Ubuntu Server 20.04 LTS, t2.small, 20GB disk)

sudo apt update
sh <(curl -L https://nixos.org/nix/install) --no-daemon

Disconnect and reconnect SSH

nix-env --version

output is: nix-env (Nix) 2.3.16

nix-channel --add https://nixbld.m-labs.hk/channel/custom/artiq/full-beta/artiq-full
nix-channel --remove nixpkgs
nix-channel --add https://nixos.org/channels/nixos-21.05 nixpkgs
nix-channel --update
cd ~
mkdir .config
mkdir .config/nix
cat > .config/nix/nix.conf <<EOF
substituters = https://cache.nixos.org https://nixbld.m-labs.hk
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nixbld.m-labs.hk-1:5aSRVA5b320xbNvu30tqxVPXpld73bhtOeH6uAjRyHc=
EOF
nix-env -iA artiq-full.artiq-env
cd ~
cat >artiq.nix <<EOF
let
  # pkgs contains the NixOS package collection. ARTIQ depends on some of them, and
  # you may want some additional packages from there.
  pkgs = import <nixpkgs> {};
  artiq-full = import <artiq-full> { inherit pkgs; };
in
  pkgs.mkShell {
    buildInputs = [
      (pkgs.python3.withPackages(ps: [
        # List desired Python packages here.

        # You probably want these two.
        artiq-full.artiq
        artiq-full.artiq-comtools

        # You need a board support package if and only if you intend to flash
        # a board (those packages contain only board firmware).
        # The lines below are only examples, you need to select appropriate
        # packages for your boards.
        #artiq-full.artiq-board-kc705-nist_clock
        #artiq-full.artiq-board-kasli-wipm
        #ps.paramiko  # needed if and only if flashing boards remotely (artiq_flash -H)

        # The NixOS package collection contains many other packages that you may find
        # interesting for your research. Here are some examples:
        #ps.pandas
        #ps.numpy
        #ps.scipy
        #ps.numba
        #(ps.matplotlib.override { enableQt = true; })
        #ps.bokeh
        #ps.cirq
        #ps.qiskit
      ]))

      # List desired non-Python packages here
      #artiq-full.openocd  # needed if and only if flashing boards
      # Other potentially interesting packages from the NixOS package collection:
      #pkgs.gtkwave
      #pkgs.spyder
      #pkgs.R
      #pkgs.julia
    ];
  }
EOF
nix-shell artiq.nix

This produces the following error message:

error: attribute 'rustLib' missing, at /nix/store/f2rxgz23bmmy55byl71v9zgmkkmd59ac-artiq-full/artiq-full/fast/rust-platform.nix:9:6
(use '--show-trace' to show detailed location information)

Attempted work-around 1

Install Ubuntu 18.04 instead of 20.04.

This does not fix the error.

Attempted work-around 2

Instead of installing the latest NIXOS (which is 2.3.16):

sh <(curl -L https://nixos.org/nix/install) --no-daemon

Install 2.3.15:

sh <(curl -L https://releases.nixos.org/nix/nix-2.3.15/install) --no-daemon

This does not fix the error.

Attempted work-around 3

During the installation, instead of adding package nixpgs from channel nixos-21.05

nix-channel --add https://nixos.org/channels/nixos-21.05 nixpkgs

add it from channel nixos-unstable:

nix-channel --add https://nixos.org/channels/nixos-unstable nixpkgs

This does not fix the error.

Attempted work-around 4

Instead of adding the artiq-full beta channel:

nix-channel --add https://nixbld.m-labs.hk/channel/custom/artiq/full-beta/artiq-full

add the normal (non-beta) artiq-full channel:

nix-channel --add https://nixbld.m-labs.hk/channel/custom/artiq/full/artiq-full

Now, the nix-shell command does not output the rustLib error message anymore:

$ nix-shell artiq.nix
these derivations will be built:
  /nix/store/qf05pk44jkdvy07n3qgf644hmg160f40-python3-3.8.11-env.drv
these paths will be fetched (6.14 MiB download, 40.65 MiB unpacked):
  /nix/store/3k69hbxg04sdxlgi1236ddggs346sxf3-stdenv-linux
[...]
  /nix/store/wkma3p801kadw9rhbnx999pm59679i09-python3.8-typing_extensions-3.7.4.3
copying path '/nix/store/7al99yyrc2ix9c5idq2kf8zgksscaf9z-bash-interactive-4.4-p23-doc' from 'https://cache.nixos.org'...
copying path '/nix/store/p5lnl4zr45n7mf9kz9w8yz3rqh001b5c-bash-interactive-4.4-p23-dev' from 'https://cache.nixos.org'...
[...]
copying path '/nix/store/7vvkamkxcvg8jqgci1qsb7dhirf3rvac-python3.8-artiq-comtools-1.1' from 'https://nixbld.m-labs.hk'...
building '/nix/store/qf05pk44jkdvy07n3qgf644hmg160f40-python3-3.8.11-env.drv'...
created 436 symlinks in user environment

This is a bug that will need fixing in nix-scripts, for now you can work around it by applying the Mozilla nixpkgs overlay in your shell.nix, e.g. something along the lines of

  pkgs = import <nixpkgs> { overlays = [ (import <artiq-full/fast/mozilla-overlay.nix>) ];  };

The stable version of ARTIQ is not affected AFAICT.

Thank you for the quick response and work around.