Warning
Still learning and trying out nix
Flake configuration for my system.
Highlights are mainly:
- btrfs with lzo compression
- zram
- impermanence
- root on tmpfs,
/homeand/nixon btrfs subvolumes - LUKS encryption
- hjem
Other minor changes are
- dbus-broker instead of regular dbus
- systemd in initrd stage 1
- iwd and resolved for networking
- nftables instead iptables for firewall
These notes are for me, yes me. Note that the sector-size=4096 is not always
available. There is also a risk with TRIM regarding encrypted SSD drives.
- luks encryption with
--sector-size=4096 --perf-no_read_workqueue --allow-discardssee this - create two partitions,
/bootand/ - format
bootwith fat32 - format
/with btrfs and lzo compression andnoatime - create subvolumes for
/nixand/home - no swap since zram is used
- continue as usual with nix flake installation
The root directory is then mounted on tmpfs while /nix and /home are on
persistent subvolumes (this means enough memory should be available).
Warning
Passwords are done using a password file stored under
/nix/persist/passwords/<username> and have to be manually created and
edited! Enter mkpasswd -m help to see a list of encryption methods.
Important
Symlinks are used for neovim config and scripts, set the environmental
variable FLAKE to point to the root flake directory.
Wrappers are used for almost everything in config. This is mainly for large applications where it benefits them immensely to write in their own config language rather than nix. For example, hyper-extensive applications like neovim or emacs. In most cases, these require FLAKE to be set.
Hjem is used alongside NixOS modules, so there is no distinction between them. This is kind of different from other configs where Home-manager and NixOS modules are separated. The modules are not as organized as I would like them to be
- config: "user" configuration, like colors or user services
- display: configuration for desktop environments
- packages: kind of obvious, just applications and packages
- system: system configuration, like non-user services or hardware config
Then you have default.nix tree importing all modules and setting defaults values. The other modules (dbus.nix, home.nix, sops.nix) provide additional, library like-utilities. Home exposes hjem and Sops exposes, well, sops-nix.
Terranix is used in packages to create a terraform file instructing incus to create instances and volumes. Packages can also have modules, for whatever reasons.
Secrets are stored elsewhere, just for fun. A quick rundown of how to use sops (for myself) is
- edit secrets:
nix-shell -p sops --run "sops secrets/example.yaml" - rekey secrets:
nix-shell -p sops --run "sops updatekeys secrets/example.yaml" - get public key:
nix-shell -p ssh-to-age --run 'cat /etc/ssh/ssh_host_ed25519_key.pub | ssh-to-age'
After adding a new key to .sop.yaml, you must rekey the secrets. This is absolutely necessary.