Is there a way to do nixos-install on remote system?

As written in the title I’m looking for a way to push a Flake config to a server running the minimal ISO.
Is there an equivalent to --target-host for nixos-install?

you can try GitHub - MatthewCroughan/nixinate: Another NixOS Deployment Tool - Nixinate your systems 🕶️

however it’s BETA! but it’s fun, it’s flake only and pure nix/bash , not a line of rust, python or anything else :-). You just need ssh access to a nixos system that has flakes enabled.

Hopefully it will do what you need, if it doesn’t, they will added it! (within reason).

Have fun!

Thank you for the input.
nixinate seems to be doing about the same things that I’m already doing just with rsync instead of git.
I currenly boot into the ISO, set an SSH password and then basically run the following commands

  1. nix-shell -p git --run "git clone"
  2. cd nixos && nix-shell
  3. sudo python3 scripts/
  4. sudo nixos-install --no-root-passwd --root /mnt --impure --flake .#SYSTEMNAME

Afterwards I update the machines with nixos-rebuild --target-host but I was hoping that there is an inbuilt way to push the initial config.


Why not use something like nix-tests/justdoit.nix at a9a316ad89bfd791df4953c1a8b4e8ed77995a18 · cleverca22/nix-tests · GitHub to brute-force install NixOS onto a given machine? All you need to do is generate an ISO which has this module in it, and will be available to execute, which basically replaces your Python script with pure nix. This justdoit example requires ZFS and UEFI though, so it may not be suitable for you, but I have enjoyed using before. It should at least give you some ideas.


This inspired me to my current solution, since I actually want to run my Python script.
I add two small scripts to my repo.
One 1 which downloads the repo with curl so that I don’t have to use git and kicks off the actually install script 2 which then runs the disk setup script and installs the provided config.

Edit: Not 100% what I was looking for but good enough.

1 Like

Maybe nixinate will get mainlined soon, so you be able just to nix inate a system, that does all this for you :-).

1 Like