Nix profile install - cannot add path - lacks a valid signature

Hello,

I am following this blog post Practical Nix Flakes

$ nix-env -f '<nixpkgs>' -iA nixUnstable
$ mkdir -p ~/.config/nix
$ echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf
$ nix profile install nixpkgs#hello
copying path '/nix/store/wkw074f3dvakiy5d006cwh50zdp0pmh4-libunistring-0.9.10' from 'https://cache.nixos.org'...
copying path '/nix/store/rrrr1hmxy2wym96yks0gk15xfh1h424v-libidn2-2.3.2' from 'https://cache.nixos.org'...
copying path '/nix/store/ff88p8pnhdmf8bflzbxldys21djw9dp0-glibc-2.33-56' from 'https://cache.nixos.org'...
copying path '/nix/store/v3m94b0jprhhr24f3b6y34dgmhf5rw8p-hello-2.10' from 'https://cache.nixos.org'...
warning: path '/nix/store/ry66219lvpa8w5kswgx1dnyanag2ik9z-profile' claims to be content-addressed but isn't
error: cannot add path '/nix/store/ry66219lvpa8w5kswgx1dnyanag2ik9z-profile' because it lacks a valid signature

Possible cause?

This is caused by having Nix 2.3 daemon, but Nix 2.4 client.
nix flakes: nix profile install always fails with "claims to be content-addressed but isn't" "because it lacks a valid signature" · Issue #4425 · NixOS/nix · GitHub

It seems to be fixed by this PR Remove the 'ca-references' feature check by edolstra · Pull Request #5247 · NixOS/nix · GitHub but I don’t know how to make it work.

I see that latest commit on tag 2.3.16 is from 2021-07-26 nix/local-store.cc at 8c5b39875edb3b88f5825cc76d1cae91b3afd130 · NixOS/nix · GitHub

And this patch is from 2021-09-14 nix/local-store.cc at 761ac9d584da967d032b51076f91d0967252412c · NixOS/nix · GitHub

This seems to be solution `nix profile install <flake>` fails on macOS with multi-user installation · Issue #5296 · NixOS/nix · GitHub

Also mentioned here Dealing with `path xyz claims to be content-addressed but isn't` - #2 by jayesh.bhoot

I have change /etc/nixos/configuration.nix like here Flakes - NixOS Wiki for " System-wide installation":

{ pkgs, ... }: {
  nix = {
    package = pkgs.nixFlakes;
    extraOptions = ''
      experimental-features = nix-command flakes
    '';
   };
}

After nixos-rebuild switch I got

$ nix --version
nix (Nix) 2.4pre20211006_53e4794

$ nix profile install nixpkgs#hello

$ hello
Hello, world!

So it works.

1 Like