Skip to content

Security and Hardening

The darkone.system.security module progressively applies the ANSSI BP-028 🡕 (GNU/Linux) hardening recommendations. Each host chooses a level and a category; the appropriate rules activate automatically.

darkone.system.security = {
enable = true;
level = "intermediary"; # minimal | intermediary | reinforced | high
category = "server"; # base | client | server
};
LevelPurpose
minimalCommon base, any system (default)
intermediaryRecommended for almost all systems
reinforcedSensitive or multi-user systems
highDedicated skills and budget (kernel recompilation)
CategoryPurpose
baseUniversal rules, always applied (default)
clientWorkstation (desktop, USB, session, locking)
serverServer (hardened network, logging, exposed services)

Some rules break legitimate use cases. Disable a group by tag:

darkone.system.security.excludes = [ "needs-hibernation" "needs-jit" ];
TagDisables
kernel-recompileCustom kernel rules (R15–R27)
no-ipv6IPv6 disabling (R13, R22)
no-macMAC / AppArmor (R37, R45)
needs-hibernationPreserves hibernation (laptops)
needs-jitAllows JIT (Java, .NET, V8, Wasm)
needs-usb-hotplugDisables USBGuard

A single rule can be bypassed with a mandatory rationale:

darkone.system.security.exceptions = {
R9.rationale = "Rootless containers required during development.";
};
  • MAC / AppArmor (R37, R45) : application confinement ; SELinux is structurally unsupported on NixOS (exceptions R46–R49 by default).
  • Firewall & network : hardened by the server category (network module).
  • fail2ban : bans IPs after repeated attempts ; service to enable in the catalogue.

Two rules require an explicit decision from the administrator :

  • systemd sandbox (R52, R55, R63) : full confinement applies to units declared in darkone.security.services.hardenedUnitsempty by default, since blind hardening would break services. Units are added on a case-by-case basis after testing.
  • Boot and encryption (R3, R5, C6) : the module warns if Secure Boot or LUKS are not detected, but does not reconfigure the boot process. These protections are declared in the host’s disk configuration (disko, lanzaboote).
darkone.security.services.hardenedUnits = [ "nginx" "gitea" ];