First attempt at NixOS installation and configuration.
Ssetup is similar to the gist where Void Linux was installed.
With NixOS the following features are listed:
- BTRFS filesystem
- Full Disk Encryption
- SystemD-boot as bootloader
Log in with root
account.
Wipe the destination disk:
wipefs -a <destination_disk>
Partitioning the destination disk with cfdisk
with the the following scheme (using a 1 TB drive):
- 1 GB as EFI partition (
<boot_partition>
) - 999 GB as Linux partition (
<root_partition>
)
Encrypt the drive with LUKS2:
cryptsetup luksFormat --type=luks2 <root_partition>
cryptsetup open <root_partition> <encrypted_partition_name>
Prepare LVM:
vgcreate <volume_group_name> /dev/mapper/<encrypted_partition_name>
lvcreate --name <logic_volume_name> -l +100%FREE <volume_group_name>
Create filesystems:
mkfs.vfat -n EFI -F 32 <boot_partition>
mkfs.btrfs -L NixOS /dev/mapper/<volume_group_name>-<logic_volume_name>
Mount partitions and create btrfs subvolumes:
export BTRFS_OPT=rw,noatime,discard=async,compress-force=zstd,space_cache=v2,commit=120
mount -o $BTRFS_OPT /dev/mapper/<volume_group_name>-<logic_volume_name> /mnt
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
btrfs subvolume create /mnt/@snapshots
btrfs subvolume create /mnt/@nix
btrfs subvolume create /mnt/@nixos-config
btrfs subvolume create /mnt/@log
umount /mnt
mount -o $BTRFS_OPT,subvol=@ /dev/mapper/<volume_group_name>-<logic_volume_name> /mnt
mkdir /mnt/home
mkdir /mnt/nix
mkdir -p /mnt/etc/nixos
mkdir -p /mnt/var/log
mount -o $BTRFS_OPT,subvol=@home /dev/mapper/<volume_group_name>-<logic_volume_name> /mnt/home/
mount -o $BTRFS_OPT,subvol=@nix /dev/mapper/<volume_group_name>-<logic_volume_name> /mnt/nix/
mount -o $BTRFS_OPT,subvol=@nixos-config /dev/mapper/<volume_group_name>-<logic_volume_name> /mnt/etc/nixos/
mount -o $BTRFS_OPT,subvol=@log /dev/mapper/<volume_group_name>-<logic_volume_name> /mnt/var/log
mkdir -p /mnt/boot/
mount -o rw,noatime <boot_partition> /mnt/boot/
Generate NixOS configuration files:
nixos-generate-config --root /mnt
Use the configuration files you find attached in this gist:
- hardware-configuration_changes.nix
- configuration.nix
- luks.nix
- audio.nix
- bluetooth.nix
- xfce.nix
Finally install the system and then poweroff
/reboot
.
nixos-install --root /mnt --cores 0
[4] https://gist.github.com/hadilq/a491ca53076f38201a8aa48a0c6afef5
[5] https://mt-caret.github.io/blog/posts/2020-06-29-optin-state.html