mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-11-24 07:44:04 +01:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
044e8c5a2a | ||
|
|
f76889a158 | ||
|
|
08a4dd2e21 |
No files matched your search
+7
-1
@@ -45,7 +45,7 @@ small, reversible controls and narrow exceptions; benchmark before adopting expe
|
||||
| Security keys | idols-ai/shoukei use a CanoKey for touch-based sudo (pam_u2f, password fallback; servers via pam_rssh and the forwarded agent), a resident `ed25519-sk` SSH key per CanoKey as the only user SSH keys for GitHub and all hosts, FIDO2 LUKS unlock on shoukei and on-card OpenPGP subkeys; key management happens only in the phone app ([setup](./security-keys.md)) | Touch-only sudo can be triggered by any same-user process, and on a server by root through the forwarded agent; losing both CanoKeys leaves only root logins with the `romantic` recovery key |
|
||||
| Secrets | agenix declarations here, encrypted data in the private nix-secrets repository | Recipients and plaintext file permissions must be reviewed; root on a recipient can read its decrypted secrets |
|
||||
| Supply chain | Locked flake inputs; explicit binary-cache trust keys on NixOS; normal user is not a Nix trusted-user | A trusted cache or imported Nix module can supply code executed as root; a lock file is not a security audit |
|
||||
| Recovery | NixOS generations, btrbk/restic, hourly read-only snapshots of the REST store, and documented backup procedures | A rollback does not undo compromised data or secrets; backup configuration alone does not prove restore works; the offsite immutable copy is still planned |
|
||||
| Recovery | NixOS generations with automatic boot fallback on the physical servers, btrbk/restic, hourly read-only snapshots of the REST store, and documented backup procedures | A rollback does not undo compromised data or secrets; backup configuration alone does not prove restore works; the offsite immutable copy is still planned |
|
||||
|
||||
Sources: [host layout](../hosts/README.md), [k3s deployment](../hosts/k8s/README.md),
|
||||
[firewall](../modules/nixos/base/networking/firewall.nix), [SSH](../modules/nixos/base/ssh.nix),
|
||||
@@ -102,6 +102,12 @@ an advisory and affected kernel versions before adding CVE claims; search snippe
|
||||
key enrollment and actual Secure Boot state with `sbctl status`; do not assume all hosts have it.
|
||||
- Secure Boot, signed boot images, kernel lockdown and module signature enforcement are distinct
|
||||
controls. Test custom kernels and NVIDIA/out-of-tree modules before extending enforcement.
|
||||
- A failed initrd on the physical servers opens a root shell after the root password
|
||||
(`boot.initrd.systemd.emergencyAccess`, the public hash in [vars](../vars/default.nix)). It adds
|
||||
no protection on shoryu, shushou and youko: Secure Boot is off, the systemd-boot editor is on and
|
||||
TPM2 unlocks LUKS on PCRs 0+7 alone, so console access already grants root through a kernel
|
||||
command-line edit. aquamarine's Lanzaboote stub ignores command-line edits while Secure Boot is
|
||||
on.
|
||||
- AppArmor is enabled, but the only explicit policy, sudo's, is in complain mode. Complain mode logs
|
||||
rather than blocks. Existing FHS-oriented abstractions need Nix store path review; this is not
|
||||
broad enforced application confinement.
|
||||
|
||||
@@ -180,8 +180,24 @@ qemu-kvm path; there are none right now.
|
||||
settings). Deploy serially (`-p 1`) and re-check VM reachability afterwards.
|
||||
- Use `boot` + a serial reboot for anything that can drop the network mid-flight — `systemd.network`
|
||||
/ `br0` changes, nixpkgs updates, or any broad rebuild.
|
||||
- `switch` enforces this through `system.switch.inhibitors` in
|
||||
[genVmHostModule.nix](../lib/genVmHostModule.nix): when the kernel, its parameters or modules, the
|
||||
initrd, systemd, `networkd.conf`, or the `br0` / uplink units change, `switch-to-configuration`
|
||||
prints `There are changes to critical components of the system` and exits before installing the
|
||||
boot loader, and Colmena reports the activation as failed. Colmena has already pointed the system
|
||||
profile at the new generation, so rerun with `just <host> boot` and reboot, or switch anyway on
|
||||
the host with `NIXOS_NO_CHECK=1 /nix/var/nix/profiles/system/bin/switch-to-configuration switch`.
|
||||
- If a host loses VM networking, check `br0` and the VM taps, or reboot the host.
|
||||
|
||||
## Boot Recovery on Physical Servers
|
||||
|
||||
`shoryu`, `shushou`, `youko` (systemd-boot) and `aquamarine` (Lanzaboote) write each new generation
|
||||
with a boot counter. After 3 boots that never reach `boot-complete.target` (ordered after
|
||||
`sysinit.target`), the entry is marked bad and the boot loader starts the newest good one. The root
|
||||
LUKS volume unlocks through TPM2 alone, so retries need no console. Failures later in boot, such as
|
||||
a broken `br0`, do not count, and a hung boot retries only after a reboot or power cycle.
|
||||
`bootctl list` shows each entry's remaining tries.
|
||||
|
||||
## Common Build Commands
|
||||
|
||||
Use the Just recipes for host configuration checks and builds:
|
||||
|
||||
@@ -39,6 +39,9 @@ in
|
||||
./idle-suspend.nix
|
||||
];
|
||||
|
||||
# A failed initrd drops to a root shell behind the root password (docs/SECURITY.md).
|
||||
boot.initrd.systemd.emergencyAccess = myvars.initialHashedPassword;
|
||||
|
||||
# Bind the board's NCT6798D SuperIO, otherwise fan RPM and board temperatures
|
||||
# are missing.
|
||||
boot.kernelModules = [ "nct6775" ];
|
||||
|
||||
@@ -26,5 +26,7 @@
|
||||
boot.lanzaboote = {
|
||||
enable = true;
|
||||
pkiBundle = "/etc/secureboot";
|
||||
# Retries need no console: root LUKS unlocks through TPM2 alone (hosts/README.md).
|
||||
bootCounting.initialTries = 3;
|
||||
};
|
||||
}
|
||||
@@ -9,6 +9,12 @@ let
|
||||
inherit (networking.hostsAddr.${hostName}) iface ipv4;
|
||||
ipv4WithMask = "${ipv4}/24";
|
||||
in
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
myvars,
|
||||
...
|
||||
}:
|
||||
{
|
||||
# CPU policy belongs to physical hosts; guests do not control hardware frequency.
|
||||
imports = [
|
||||
@@ -30,6 +36,12 @@ in
|
||||
"nfs"
|
||||
];
|
||||
|
||||
# Retries need no console: root LUKS unlocks through TPM2 alone (hosts/README.md).
|
||||
boot.loader.systemd-boot.bootCounting.enable = true;
|
||||
|
||||
# A failed initrd drops to a root shell behind the root password (docs/SECURITY.md).
|
||||
boot.initrd.systemd.emergencyAccess = myvars.initialHashedPassword;
|
||||
|
||||
# KVM for the microVMs and the libvirt domains. AMD-specific: an Intel VM host
|
||||
# would need kvm-intel instead (see hosts/idols-ai/hardware-intel.nix).
|
||||
boot.kernelModules = [ "kvm-amd" ];
|
||||
@@ -139,6 +151,22 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
# `switch` refuses changes that only a reboot applies or that can drop br0 mid-flight; deploy
|
||||
# those with `boot` (hosts/README.md). Guest tap units are left out so a new guest still switches.
|
||||
system.switch.inhibitors = {
|
||||
kernel = toString config.system.build.kernel;
|
||||
kernel-params = toString config.boot.kernelParams;
|
||||
kernel-modules = toString config.system.modulesTree;
|
||||
initrd = toString config.system.build.initialRamdisk;
|
||||
systemd = toString config.systemd.package;
|
||||
}
|
||||
// lib.genAttrs [
|
||||
"systemd/networkd.conf"
|
||||
"systemd/network/10-br0.netdev"
|
||||
"systemd/network/10-br0.network"
|
||||
"systemd/network/20-${iface}.network"
|
||||
] (name: toString config.environment.etc.${name}.source);
|
||||
|
||||
# systemd-journal - cap disk usage, but keep plenty of history on the big
|
||||
# persistent disk (/var/log is preserved to /persistent).
|
||||
# https://www.freedesktop.org/software/systemd/man/latest/journald.conf.html
|
||||
|
||||
Reference in new issue
Block a user