Remotely Deployed Configuration not used after Reboot

I am following this v nice post: Haskell for all: NixOS in production

When I deploy to a remote PC, e.g.

nix copy -s --to "ssh://ipc127e_root" ./result;
ssh ipc127e_root "/nix/store/$H-nixos-system-LSSc-1-21.11pre-git/bin/switch-to-configuration switch; nix-env --profile /nix/var/nix/profiles/system --set /nix/store/$H-nixos-system-LSSc-1-21.11pre-git/"

everything works.

But when I reboot the latest configuration doesn’t survive.

If I run the same directly on the machine:

/nix/store/$H-nixos-system-LSSc-1-21.11pre-git/bin/switch-to-configuration switch; nix-env --profile /nix/var/nix/profiles/system --set /nix/store/$H-nixos-system-LSSc-1-21.11pre-git/

then reboot I see the latest configuration is booted up as expected.

I must be doing something silly. Any tips?

I have encountered this issue also several times with a machine and haven’t figured out yet why.

1 Like

Shouldn’t you add the generation to the profile first? The activation script uses the profile links to create the bootloader configuration, so it won’t pick up the new generation unless it’s already in the profile, I think.

1 Like

I use the following command which works fine, you have to adapt it for a non flake config.

nixos-rebuild switch -j auto --use-remote-sudo --build-host localhost --target-host $fqdn --flake ".#$host"

Maybe this helps as well:


If I do that I get this error:

error: getting status of '/home/nixos/lss-collector/switch': No such file or directory

But, you are basically right, this hack works for example:

/nix/store/$H-nixos-system-LSSc-1-21.11pre-git/bin/switch-to-configuration switch;
nix-env --profile /nix/var/nix/profiles/system --set /nix/store/$H-nixos-system-LSSc-1-21.11pre-git/;
/nix/store/$H-nixos-system-LSSc-1-21.11pre-git/bin/switch-to-configuration switch;

I.e. the extra “switch” does the job…

Thanks, I came up with a hack which works. I need to investigate the proper way of doing things : )