Aly Raffauf
54a3e71398
* flake.lock: Update Flake lock file updates: • Updated input 'disko': 'github:nix-community/disko/276a0d055a720691912c6a34abb724e395c8e38a?narHash=sha256-GkXQIoZmW2zCPp1YFtAYGg/xHNyFH/Mgm79lcs81rq0%3D' (2024-08-15) → 'github:nix-community/disko/435737144be0259559ca3b43f7d72252b1fdcc1b?narHash=sha256-zgB1Cfk46irIsto8666yLdKjqKdBrjR48Dd3lhQ0CnQ%3D' (2024-08-22) • Updated input 'nixpkgs': 'github:nixos/nixpkgs/c3d4ac725177c030b1e289015989da2ad9d56af0?narHash=sha256-sqLwJcHYeWLOeP/XoLwAtYjr01TISlkOfz%2BNG82pbdg%3D' (2024-08-15) → 'github:nixos/nixpkgs/797f7dc49e0bc7fab4b57c021cdf68f595e47841?narHash=sha256-Qb9MhKBUTCfWg/wqqaxt89Xfi6qTD3XpTzQ9eXi3JmE%3D' (2024-08-22) • Updated input 'nixpkgs-unstable': 'github:nixos/nixpkgs/c3aa7b8938b17aebd2deecf7be0636000d62a2b9?narHash=sha256-med8%2B5DSWa2UnOqtdICndjDAEjxr5D7zaIiK4pn0Q7c%3D' (2024-08-14) → 'github:nixos/nixpkgs/c374d94f1536013ca8e92341b540eba4c22f9c62?narHash=sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh%2BaRKoCdaAv5fiO0%3D' (2024-08-21) • Updated input 'nur': 'github:nix-community/NUR/b470c3a990467cf279735a013759ac85681277c8?narHash=sha256-fIQcPhJ8OCRlmCfedEcK6PI8QFIadP3f%2BYhcVnNPyRg%3D' (2024-08-17) → 'github:nix-community/NUR/462a265d0e5e12581e317dfa73482d3c4fb89d50?narHash=sha256-UmFzK4tb05MXI%2BBCD2tmBsCQV4oXPhWlbzYIlJnkXDY%3D' (2024-08-24) • Updated input 'raffauflabs': 'github:alyraffauf/raffauflabs/aca402c31573d02a94d68effb17b46687d7a6bdb?narHash=sha256-VcJG4DKjR/9NQejdpSbyXpvS554ecFdc6OP21ywt1Lk%3D' (2024-08-12) → 'github:alyraffauf/raffauflabs/fd6bb8de83bb23f0724cf464fe6ac4a3f07ed831?narHash=sha256-2be2gK4DRyPwLbddSQ5A9I9UjLM/tGrgdltrosE2AsU%3D' (2024-08-19) • Updated input 'stylix': 'github:danth/stylix/6858d08ed012bc6491cc92c13142104e56badf31?narHash=sha256-PkJTr9DWBQcR5Ru1fJpG80dtw0MLSxAZlKnhHHFAGIA%3D' (2024-08-16) → 'github:danth/stylix/d042af478ce87e188139480922a3085218194106?narHash=sha256-fH1lyJvJjUhZ8xMlmiI18EZNzodDSe74rFuwlZDL0aQ%3D' (2024-08-23) • Added input 'stylix/flake-utils': 'github:numtide/flake-utils/b1d9ab70662946ef0850d488da1c9019f3a9752a?narHash=sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ%3D' (2024-03-11) • Added input 'stylix/flake-utils/systems': follows 'stylix/systems' • Added input 'stylix/systems': 'github:nix-systems/default/da67096a3b9bf56a91d16901293e51ba5b49a27e?narHash=sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768%3D' (2023-04-09) * lavaridge: don't force kernel 6.9 * flake: update nixhw --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> |
||
---|---|---|
.. | ||
fallarbor | ||
lavaridge | ||
mauville | ||
petalburg | ||
rustboro | ||
slateport | ||
README.md |
Hosts
Overview
Host-specific configuration + common modules that aren't better expressed as options & flake outputs. All hosts are configured with agenix, disko, and nixhw.
Automatic Updates
These hosts update themselves automatically, once a day, by rebuilding from one of two sources: directly from this repository's master branch or from FlakeHub. This can be adjusted by overriding the value of config.environment.variables.FLAKE
.
FlakeHub allows semantic versioning, which means that these hosts build from the lattest tag published to FlakeHub with format v0.0.0
. I try to follow the semantic versioning 2.0 standard, though this may not always be the case.
You can access the latest tagged commit from this repository with this url: https://flakehub.com/f/alyraffauf/nixcfg/*.tar.gz.
Declarative WiFi Connections
WiFi networks can be configured declaratiely in wifi.nix
using config.networking.networkmanager.ensureProfiles.profiles
, provided by nixpkgs. I also provide helper functions for common wifi security types.
nm2nix can generate nix code for all WiFi networks currently configured in /etc/NetworkManager/system-connections/
and /run/NetworkManager/system-connections
with the following command:
sudo su -c "cd /etc/NetworkManager/system-connections && nix --extra-experimental-features 'nix-command flakes' run github:Janik-Haag/nm2nix | nix --extra-experimental-features 'nix-command flakes' run nixpkgs#nixfmt-rfc-style"
Secrets (passwords, certificates, and identities) are supported, but must be declared and available as variables with agenix. They will be replaced upon activation with envsubst
.
In short,
- Manually configure the WiFi network on one device.
- Export configuration to nix with
nm2nix
. - Add secrets to
secrets/wifi.age
as variables (e.g.MYPSK=1234567890
) - Edit the code generated by
nm2nix
to reference$MYPSK
instead of directly declaring the WPA password. - Commit and push changes.
- Rebuild hosts as required to propogate your new WiFi configuration.
Provisioning New Devices
- Create
hosts/$HOSTNAME/default.nix
and other host-specific nix modules (e.g.disko.nix
,hardware.nix
, andhome.nix
). - Add host to
nixosConfigurations
inflake.nix
. - (OPTIONAL) Generate a
cert.pem
,key.pem
, and device ID for Syncthing withsyncthing -generate=$HOSTNAME
. Find the device ID in the generatedconfig.xml
and add it tonixosModules/services/syncthing/default.nix
, encrypt the cert and key with agenix, and set them as appropriate in the host configuration. - Install NixOS from this flake. Secrets will not be available on first boot without a valid SSH private key.
- On a separate PC, copy the new system's public SSH key (
/etc/ssh/ssh_host_ed25519_key.pub
) to the host configuration (secrets/publicKeys/root_$HOSTNAME.pub
). - Add the new public key to
secrets/secrets.nix
, rekey all secrets withagenix --rekey
, and push your changes to master. - Rebuild the new system from git. Secrets will be automatically decrypted and immediately available in
/run/agenix/
for NixOS and$XDG_RUNTIME_DIR/agenix/
for users. - (OPTIONAL) Generate a new user SSH key and add it to
nixosModules/users/default.nix
in order to enable passwordless logins to other hosts.
Secure Boot
-
Generate secure boot keys:
sudo nix run nixpkgs#sbctl create-keys
-
Enable lanzaboote in NixOS host configuration:
boot = { initrd.systemd.enable = true; # For automatic decryption with TPM. loader.systemd-boot.enable = lib.mkForce false; # Interferes with lanzaboote and must be force-disabled. lanzaboote = { enable = true; pkiBundle = "/etc/secureboot"; }; };
-
In UEFI, set secure boot to "setup mode" or erase platform keys.
-
Enroll your secure boot keys:
sudo nix run nixpkgs#sbctl -- enroll-keys --microsoft
-
Reboot, make sure secure boot is enabled in UEFI.
-
Check secure boot status with
bootctl status
:System: Firmware: UEFI 2.70 (American Megatrends 5.17) Firmware Arch: x64 Secure Boot: enabled (user) TPM2 Support: yes Measured UKI: yes Boot into FW: supported
-
If your root drive is encrypted with LUKS, you can have the TPM automatically decrypt it on boot:
sudo systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+2+7+12 --wipe-slot=tpm2 /dev/nvme0n1p2
Replace
/dev/nvme0n1p2
with your root partition. Check the Linux TPM PCR Registry for more details.NOTE: This requires a TPM2 module, devices with prior versions will not work.