Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --target-host to nixos-generate-config and nixos-install #217891

Open
roberth opened this issue Feb 23, 2023 · 2 comments
Open

Add --target-host to nixos-generate-config and nixos-install #217891

roberth opened this issue Feb 23, 2023 · 2 comments

Comments

@roberth
Copy link
Member

roberth commented Feb 23, 2023

Project description

Adding a --target-host option (like nixos-rebuild has) to these tools will make remote installations much easier, and allows ad hoc installation on lightweight hardware that may not be big enough to evaluate its config.

Example work flow:

  1. Write an installer image and boot it on the target host
  2. Prepare and mount the file systems
  3. nixos-generate-config --target-host HOST --root /mnt --dir .
    • connects with ssh to HOST
    • runs the local copy of nixos-generate-config with --root /mnt --dir $tmp
    • copies the files back to the local directory from --dir. --dir is mandatory when --target-host is specified
  4. Write a flake locally to import that configuration.nix into nixosConfigurations.host
  5. nixos-install --target-host HOST --root /mnt --flake .#host
    • builds the configuration locally
    • copies a closure including nixos-install script. nixos-install need not be part of toplevel for this to work!
    • invokes the installation process over ssh

Nice to have:

  • run the installation in tmux or screen
@Majiir
Copy link
Contributor

Majiir commented Feb 28, 2023

As a workaround, I have done this manually:

  1. nixos-rebuild build --flake <flake>
  2. nix-copy-closure --to <host> result
  3. (on remote) nixos-install --system <system-closure>

Of course, that requires nixos-install on the target!

@roberth
Copy link
Member Author

roberth commented Feb 28, 2023

I think that's nixos-rebuild build in (1)?

Of course, that requires nixos-install on the target!

Ideally we shouldn't even need nixos-rebuild on the target. I think it only needs to copy the closure, set the profile and call activate. On the target, nix should suffice, even just a store-only one:

Such minimalism is up to the final configuration though. It seems like a good tradeoff to keep some of these commands on the installation media configurations:

  • runs the local copy of nixos-generate-config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants