This is an old revision of the document!
Table of Contents
NixOS
Install in-place
Infect system using nixos-infect
Ensure you're root when executing the commands (sudo -i)
touch /etc/ssh/ssh_host_placeholder_key curl https://raw.githubusercontent.com/elitak/nixos-infect/master/nixos-infect | NIX_CHANNEL=nixos-24.11 NO_REBOOT=1 bash -x
Apply configuration
First check-out desired configuration into `/etc/nixos.
# Change owner to primary user if you want to edit it from the primary user chown -R 1000:1000 /etc/nixos git clone <NIXOS-GIT-REPOSITORY> /etc/nixos
Then restart system once so NixOS replaces the currently installed system. Afterwards boot another NixOS system (e.g. from another partition or live CD) to adjust system configuration for example LUKS partitions.
When second NixOS system is booted mount your system into `/mnt` including additional partitions like boot partition (into their respective directories). Afterwards invoke `nixos-enter` to enter a shell simulating the future NixOS system.
mount /dev/disk/by-id/xxxx-part1 /mnt mount /dev/disk/by-id/xxxx-part2 /mnt/boot nixos-enter
Now adjust your configuration to add/support this system and its hardware. Also keep in mind that if you're using LUKS for your primary partition/disk you need to manually add it to the generated hardware configuration to support it.
# Adjust files in /etc/nixos to support this system nixos-generate-config > /etc/nixos/hardware-configuration.nix
Now activate the configuration on next boot.
nix-env --set \ -I nixpkgs=$(realpath $HOME/.nix-defexpr/channels/nixos) \ -f '<nixpkgs/nixos>' \ -p /nix/var/nix/profiles/system \ -A system /nix/var/nix/profiles/system/bin/switch-to-configuration boot # this might also work instead of the above commands # nixos-rebuild boot