Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Compliance

NixFleet’s compliance layer ships in the nixfleet-compliance companion repository - a standalone collection of regulatory controls, framework presets, and evidence probes for NixOS hosts.

Each control enforces a security measure and produces machine-readable evidence via probes. Evidence is collected on a schedule and written to /var/lib/nixfleet-compliance/evidence.json. The governance engine lets fleet operators set enforcement levels, host-type scoping, and per-rule exceptions with mandatory rationale.

Repository: github.com/arcanesys/nixfleet-compliance - MIT licensed, works standalone or alongside nixfleet and nixfleet-scopes.

Quick Start

{
  inputs.compliance.url = "github:arcanesys/nixfleet-compliance";
  # In your mkHost modules:
  modules = [
    compliance.nixosModules.nis2
    {
      compliance.frameworks.nis2 = {
        enable = true;
        entityType = "essential";
      };
    }
  ];
}

Frameworks

FrameworkRegulationControlsDifferentiation
NIS2Directive 2022/255512essential vs important
DORARegulation 2022/25549critical provider vs standard
ISO 27001ISO/IEC 27001:202214full vs partial scope
ANSSIBP-028 v2.07minimal / intermediary / reinforced / high

Controls

ControlWhat it enforces
access-controlSSH key-only auth, root login disabled, idle session timeout
asset-inventoryHost, service, and network inventory from running system
audit-loggingJournald persistence, auditd with execve tracking, log retention
authenticationMFA policy, PAM modules, SSH certificate auth
backup-retentionBackup service verification, last backup age, retention compliance
baseline-hardeningKernel sysctl, IOMMU, filesystem permissions (ANSSI R7-R14)
change-managementSystem rebuild freshness, generation frequency
disaster-recoveryGeneration retention, RTO target, recovery test interval
encryption-at-restLUKS verification, encrypted swap, tmpfs /tmp
encryption-in-transitTLS minimum version, certificate inventory and expiry
incident-responseRollback readiness, journal availability, alert retention
key-managementSSH host key age and algorithm, LUKS key slots, rotation policy
network-segmentationFirewall status, VLAN detection, interface inventory
secure-bootEFI support, secure boot status, signed unified kernel images
supply-chainflake.lock pinning, SBOM generation, nixpkgs staleness
vulnerability-mgmtNixpkgs freshness, scan interval, critical vulnerability blocking

Governance

OptionValuesDescription
enforceModeenforce, reportEnforce applies NixOS config and runs probes; report only runs probes
levelminimal, standard, strict, paranoidRules above this severity threshold are auto-disabled
hostTypeserver, workstation, applianceRules scope themselves to matching host types
excludeslist of tagsTag-based rule exclusions (e.g., ["no-ipv6"])
exceptionsattrs with rationalePer-rule exceptions with mandatory reason, included in audit report
compliance.governance = {
  enforceMode = "enforce";
  level = "standard";
  hostType = "server";
  exceptions.BH-07 = {
    rationale = "IPv6 required for internal mesh networking";
  };
};

Evidence Collection

Probes run on a configurable schedule - hourly for essential/critical entities, daily for important/standard - and produce JSON. The compliance-check CLI runs all probes interactively:

compliance-check              # colored summary
VERBOSE=1 compliance-check    # detailed JSON per control

Framework Mappings

For detailed article-by-article regulatory mappings:

NixOS Advantage

NixOS provides unique compliance properties. flake.lock is a cryptographically verifiable supply chain manifest - every input is pinned by hash. Content-addressing makes binary tampering detectable. Impermanence prevents malware persistence by wiping the root filesystem on every reboot. Declarative configuration means the audit configuration IS the actual running configuration - there is no drift between what was approved and what is deployed.