Aly Raffauf
c7a6cd8773
Some checks failed
git-mirror / gitlab-sync (push) Has been cancelled
nix-build / adjustor-build (push) Has been cancelled
nix-build / clean-install-build (push) Has been cancelled
nix-build / emudeck-build (push) Has been cancelled
nix-build / hhd-ui-build (push) Has been cancelled
nix-build / rofi-bluetooth-build (push) Has been cancelled
nix-build / fallarbor-build (push) Has been cancelled
nix-build / lavaridge-build (push) Has been cancelled
nix-build / mauville-build (push) Has been cancelled
nix-build / pacifidlog-build (push) Has been cancelled
nix-build / petalburg-build (push) Has been cancelled
nix-build / rustboro-build (push) Has been cancelled
nix-build / slateport-build (push) Has been cancelled
nix-check / fmt-check (push) Has been cancelled
nix-check / eval-check (push) Has been cancelled
* flake.lock: Update Flake lock file updates: • Updated input 'disko': 'github:nix-community/disko/341482e2f4d888e3f60cae1c12c3df896e7230d8?narHash=sha256-i%2BUw8VOHzQe9YdNwKRbzvaPWLE07tYVqUDzSFTXhRgk%3D' (2024-11-27) → 'github:nix-community/disko/2814a5224a47ca19e858e027f7e8bff74a8ea9f1?narHash=sha256-2uMaVAZn7fiyTUGhKgleuLYe5%2BEAAYB/diKxrM7g3as%3D' (2024-11-30) • Updated input 'home-manager': 'github:nix-community/home-manager/2f7739d01080feb4549524e8f6927669b61c6ee3?narHash=sha256-6TrknJ8CpvSSF4gviQSeD%2Bwyj3siRcMvdBKhOXkEMKU%3D' (2024-11-28) → 'github:nix-community/home-manager/819f682269f4e002884702b87e445c82840c68f2?narHash=sha256-r8j6R3nrvwbT1aUp4EPQ1KC7gm0pu9VcV1aNaB%2BXG6Q%3D' (2024-11-29) • Updated input 'nix-gaming': 'github:fufexan/nix-gaming/effe1d54e23f430d3e803f63e9e47aba33acfb63?narHash=sha256-divlhUduT0/t8D9k11Yd3Ah3xpr302vV1KXxIMb8I3M%3D' (2024-11-28) → 'github:fufexan/nix-gaming/59363ec701ee3e994a6c8afc88b61d1fab40c66a?narHash=sha256-RIvcgs8yGix6g6694omcGpvAza5LxZfV5LmyXsw8c0I%3D' (2024-12-01) • Updated input 'nix-gaming/umu': 'git+https://github.com/Open-Wine-Components/umu-launcher/?dir=packaging/nix&ref=refs/heads/main&rev=f6a6af3191f5497d95d8f8aaa08826a45da199c4&submodules=1' (2024-11-23) → 'git+https://github.com/Open-Wine-Components/umu-launcher/?dir=packaging/nix&ref=refs/heads/main&rev=3277b47c9f87ecf736e1df7ed65cc0e25466f9b2&submodules=1' (2024-11-29) • Updated input 'nixpkgs': 'github:nixos/nixpkgs/4633a7c72337ea8fd23a4f2ba3972865e3ec685d?narHash=sha256-2ThgXBUXAE1oFsVATK1ZX9IjPcS4nKFOAjhPNKuiMn0%3D' (2024-11-25) → 'github:nixos/nixpkgs/970e93b9f82e2a0f3675757eb0bfc73297cc6370?narHash=sha256-jNRNr49UiuIwaarqijgdTR2qLPifxsVhlJrKzQ8XUIE%3D' (2024-11-28) • Updated input 'nur': 'github:nix-community/NUR/cc2a3158b6a714b98a8b891d6dcfc3a43039051f?narHash=sha256-ZliP697Djpq%2BJM4MuO6kvj5RWjCdg39ZQ2moFoqFbdE%3D' (2024-11-29) → 'github:nix-community/NUR/bddf3b72b641f9116c770ea5115d192f27c48f91?narHash=sha256-alQFJwNHVkXrZEkxQ6lK/pybjjJ3q4sYniXhsJphBnM%3D' (2024-12-01) • Updated input 'stylix': 'github:danth/stylix/7689e621f87bce7b6ab1925dfd70ad1f4c80f334?narHash=sha256-T5k5ill%2BPNIEW6KuS4CpUacMtZNJe2J2q5eBOF4xWuU%3D' (2024-11-26) → 'github:danth/stylix/d13ffb381c83b6139b9d67feff7addf18f8408fe?narHash=sha256-t1J6wgzGjvvGNfdd0ei8HnZf9sTw%2BSpvCNAX0i6Qgwc%3D' (2024-11-30) * tree-wide: migrate nerdfonts to new nerd-fonts namespace --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> |
||
---|---|---|
.. | ||
fallarbor | ||
lavaridge | ||
mauville | ||
pacifidlog | ||
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 directly from one of this repository's branches, typically master.
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.