cfdisk /dev/sda
/dev/sda1 | /boot/efi | FAT | 255MB |
/dev/sda2 | / | Btrfs | 20GB |
mkfs.fat /dev/sda1
cryptsetup luksFormat /dev/sda2
cryptsetup open /dev/sda2 root
mkfs.btrfs -L root /dev/mapper/root
mount /dev/mapper/root /mnt
mkdir -p /mnt/boot
mount /dev/sda1 /mnt/boot
Create swap file on Btrfs
truncate -s 0 /mnt/var/swapfile
chattr +C /mnt/var/swapfile
fallocate -l 4G /mnt/var/swapfile
chmod 600 /mnt/var/swapfile
mkswap /mnt/var/swapfile
Generate hardware configuration.
nixos-generate-config --root /mnt
Move hardware-configuration.nix
.
mv /mnt/etc/nixos/hardware-configuration.nix /next/to/configuration.nix
ln -sf /path/to/configuration.nix /mnt/etc/nixos
nixos-install
Reboot into the new NixOS system.
sh <(curl -L https://nixos.org/nix/install) --daemon
# install nixos-generate-config
nix-env -iE "_: with import <nixpkgs/nixos> { configuration = {}; }; with config.system.build; [ nixos-generate-config nixos-install nixos-enter ]"
nixos-generate-config
nix-env -p /nix/var/nix/profiles/system -f '<nixpkgs/nixos>' -I nixos-config=/etc/nixos/configuration.nix -iA system
touch /etc/NIXOS
echo etc/nixos > /etc/NIXOS_LUSTRATE
echo var/swapfile >> /etc/NIXOS_LUSTRATE
echo gnu >> /etc/NIXOS_LUSTRATE
echo etc/guix >> /etc/NIXOS_LUSTRATE
echo var/guix >> /etc/NIXOS_LUSTRATE
mv -v /boot /boot.bak
/nix/var/nix/profiles/system/bin/switch-to-configuration boot
Enable unstable channels
nix-channel --add https://nixos.org/channels/nixos-unstable nixos
nix-channel --update
nix-store --generate-binary-cache-key $hostname /etc/nix/signing-key.sec /etc/nix/signing-key.pub