Remote nixos-rebuild and "--add-root" warning

I’m trying out nixos-rebuild’s remote build feature with a command like this

nixos-rebuild switch --fast --flake .#host --target-host host --build-host host --use-remote-sudo

It correctly activated the configuration, but also generated a warning:

warning: you did not specify '--add-root'; the result might be removed by the garbage collector

Is it something I should be concerned about? I don’t really understand gcroots that well, but is the warning telling me that the configuration isn’t reachable from a gcroot?

gcroots are used to tell the Nix garbage collector which store paths are still in use by a NixOS configuration, devShell, etc. and thus should not be considered for garbage collection. You can find them inside /nix/var/nix/gcroots.

I’ve been startled by this warning some time ago as well, decided to look inside /nix/var/nix/profiles/ and /nix/var/nix/gcroots/ and found that everything is fine there. There was /nix/var/nix/profiles/system, which pointed to the latest generation of that NixOS system and in /nix/var/nix/gcroots/auto there was a symlink to the store path of that latest generation. So I assume the warning nixos-rebuild shows here refers to localhost, i.e. the one you are running nixos-rebuild from.

1 Like