Can I build a remote nixos 21.11 system from my unstable laptop?

In the past I’ve run a command like this on my laptop to build a new configuration on my laptop and install it to remote server:

nixos-rebuild switch --upgrade --build-host localhost --target-host root@machine-b -I nixos-config=/home/someguy/projects/nixos/machine-b/configuration.nix

This is nice because I can keep all the nix files on my laptop, let my laptop do all the heavy lifting, etc.

But that means if I want to build 21.11 remote systems then I have to keep my laptop on 21.11 .

What I really want to do is run unstable on my laptop but build 21.11 systems from it using nixos-rebuild.


PS. I do have a third system available (call it BigBox) running 21.11 that I could do the builds on. But I still want the config.nix to live on my laptop only.

You can use flakes, those pretty much solve the Problem.

Also you can use distributed builds to use external builders.


I haven’t tested this, but wouldn’t passing -I nixpkgs=/path/to/nixpkgs-at-21.11 do the trick?


I second this. Once you have converted your system configuration to a flake, it’s as simple as running
nixos-rebuild --target-host root@REMOTE --flake '/path/to/flake#hostname' switch
It is also much more reproducible than not using flakes.

1 Like

This is basically the design around nixinate, GitHub - MatthewCroughan/nixinate: Another NixOS Deployment Tool - Nixinate your systems 🕶️

join the beta, or don’t.

1 Like

@NobbZ @aidalgol flakes did the trick! Thanks :slight_smile: