To remotely install NixOS onto a target system, I use nixos-anywhere.
On the target system:
-
Boot the NixOS iso
-
Configure SSH authorized keys to enable SSH into the system
[nixos@nixos:~]$ mkdir .ssh && curl https://github.com/brenix.keys > .ssh/authorized_keys
-
Note the IP address of the system
On a separate NixOS host:
-
Pull or
cd
to the directory for this repository -
Enter the dev shell
$ nix develop
-
Run ssh-to-age to get a pubkey for SOPS
$ ssh-keyscan $TARGET_HOST | ssh-to-age
-
Update the
.sops.yaml
file and add a new host to the keys and creation rules -
Update all of the secrets in the repo to include the new key
$ make updatekeys
-
Run nixos-anywhere to remotely install NixOS on the target system
$ nixos-anywhere --no-reboot --flake '.#neo' [email protected] # Replace with the target system IP from above
On the target system:
-
Copy the livecd ssh host keys to the persist directory
$ sudo mkdir -p /mnt/persist/etc/ssh && sudo cp /etc/ssh/ssh_host_ed25519* /mnt/persist/etc/ssh/
I use a Makefile to simplify running of some commands
Make Target:
make nixos
CLI:
sudo nixos-rebuild switch --verbose --flake ".#hostname"
Make Target:
make home
CLI:
home-manager switch --flake ".#username@hostname"
Bootstrap:
nix run home-manager -- switch --flake ".#username@hostname"
Make Target:
make nixos
CLI:
darwin-rebuild switch --verbose --flake ".#macbook"
Bootstrap:
nix run darwin-rebuild -- switch --flake ".#macbook"
Some features of my nix-config:
- Structured to allow multiple NixOS configurations, including desktop, laptop
- Declarative config including themes and wallpapers
- Opt-in persistance through impermanence + blank snapshot
- Encrypted btrfs partition
- sops-nix for secrets management
- Custom live media ISO, with an "automated" install script
- Supports vfio for playing games on Windows
neo
: My primary desktop computermorpheus
: Framework 13th gen laptoptrinity
: My spare desktop now used as a K8S servervm
: Qemu VM for testingiso
: Builds custom installer ISO
Type | Program |
---|---|
OS | NixOS |
Editor | Helix |
Multiplexer | Zellij |
Prompt | Starship |
Launcher | Rofi |
Shell | Fish |
Status Bar | Waybar |
Terminal | Foot |
Window Manager | Hyprland |
Fonts | Monaco |
Colorscheme | Catppuccin Mocha |
- A lot of the configuration and inspiration comes from https://github.com/hmajid2301/dotfiles
- For some additional snowfall/darwin config: https://github.com/jakehamilton/config
- Originally inspired by https://github.com/Misterio77/nix-config