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

Scopes & Roles

NixFleet uses a scope system to compose host configurations. Scopes ship in the nixfleet-scopes companion repository - a standalone collection of infrastructure modules, roles, and disk templates that work with any NixFleet-managed host.

Scopes are NixOS modules that self-activate based on configuration flags. Each scope wraps its config block in lib.mkIf so it produces no configuration when its condition is false. Options live under nixfleet.*. Roles compose scopes and set defaults with lib.mkDefault - consumers override with lib.mkForce when needed.

Repository: github.com/arcanesys/nixfleet-scopes - MIT licensed, works standalone or via inputs.nixfleet.scopes re-export.

Framework Service Scopes

These ship with NixFleet and are auto-included by mkHost (disabled by default).

ScopeOptionsDescription
Agentservices.nixfleet-agent.*Deploy cycle daemon - polls CP, applies generations, reports health
Agent (Darwin)services.nixfleet-agent.*macOS variant using launchd
Control Planeservices.nixfleet-control-plane.*Axum HTTP with mTLS, SQLite, RBAC for fleet orchestration
Cache Serverservices.nixfleet-cache-server.*Harmonia-based Nix binary cache serving from local store
Cacheservices.nixfleet-cache.*Nix substituter pointing to fleet cache
MicroVM Hostservices.nixfleet-microvm-host.*MicroVM hypervisor with bridge networking, DHCP, and NAT

The impermanence scope from nixfleet-scopes is also auto-imported by mkHost. It is inert unless nixfleet.impermanence.enable is set.

Infrastructure Scopes

From nixfleet-scopes. Import via roles or individually.

ScopeNamespaceDescription
basenixfleet.baseUniversal CLI tools (ifconfig, netstat, xdg-utils). Darwin and HM variants available.
operatorsnixfleet.operatorsMulti-user management - primary user, SSH keys, sudo, shell, HM routing, role groups
firewallnixfleet.firewallnftables backend, SSH rate limiting (5/min), drop logging, microVM bridge forwarding
secretsnixfleet.secretsBackend-agnostic identity paths for agenix/sops-nix, boot ordering, key validation
backupnixfleet.backupTimer scaffolding with restic and borgbackup backends, pre/post hooks, health pings
monitoringnixfleet.monitoringPrometheus node exporter with fleet-tuned collector defaults
monitoring-servernixfleet.monitoring.serverPrometheus server with scrape configs, retention, and built-in alert rules
impermanencenixfleet.impermanenceBtrfs root wipe + system persist paths (/etc/nixos, /var/lib/systemd, /var/log, etc.)
home-managernixfleet.home-managerHM integration - useGlobalPkgs/useUserPackages defaults, fans out profileImports to HM-enabled operators
diskonixfleet.diskoDisko NixOS module injection (inert without disko.devices)
o11ynixfleet.o11yMetrics remote-write (vmagent to VictoriaMetrics/Mimir) + journal log shipping
vpnnixfleet.vpnProfile-driven VPN framework with wireguard driver
compliancenixfleet.complianceFilesystem integration for compliance evidence - persists evidence dir, sets configurationRevision
generation-labelnixfleet.generationLabelRich boot entry labels from flake metadata (date, rev, deterministic codename)
remote-buildersnixfleet.distributedBuildsCross-platform distributed build delegation (handles Determinate Nix on Darwin)
hardwarenixfleet.hardwareAuto-imports hardware sub-modules: microcode, bluetooth, nvidia, wake-on-LAN, memory/zram, legacy boot
terminal-compatnixfleet.terminalCompatTerminfo for modern terminals (kitty, alacritty) + headless tools (curl, wget, unzip)

Platform variants exist for: base (Darwin, HM), operators (Darwin), backup (Darwin), impermanence (HM), home-manager (Darwin).

Operators

The operators scope manages user accounts declaratively. One operator is designated primaryUser - the identity anchor for Home Manager, secrets, and impermanence paths.

Each operator (users.<name>) supports:

  • isAdmin - adds wheel group (sudo access)
  • sshAuthorizedKeys - SSH public keys for authorized_keys
  • shell - login shell (default: bash)
  • homeManager.enable - apply the profile’s HM stack to this operator
  • hashedPassword / hashedPasswordFile - password authentication
  • extraGroups - additional groups on top of roleGroups

Top-level options:

  • primaryUser - identity anchor (auto-detected when only one operator exists)
  • roleGroups - groups added to all operators (set by roles, e.g. workstation adds networkmanager/video/audio/docker)
  • rootSshKeys - root SSH access, independent of operator accounts
  • mutableUsers - allow imperative passwd changes (default: false)
nixfleet.operators = {
  primaryUser = "alice";
  users.alice = {
    isAdmin = true;
    sshAuthorizedKeys = [ "ssh-ed25519 AAAA... alice@workstation" ];
    homeManager.enable = true;
    shell = pkgs.zsh;
  };
  users.bob = {
    sshAuthorizedKeys = [ "ssh-ed25519 BBBB... bob@laptop" ];
  };
  rootSshKeys = config.nixfleet.operators._adminSshKeys;
};

Roles

Roles compose scopes with sensible defaults. Import one role per host.

RoleTypeScopes importedKey defaults
serverHeadlessbase, operators, firewall, secrets, monitoring, impermanence, o11y, generation-label, terminal-compat, hardwareFirewall on, secrets on, monitoring on, o11y metrics on, no user key, no roleGroups
workstationInteractivebase, operators, firewall, secrets, home-manager, backup, impermanence, o11y, generation-label, terminal-compat, hardwareFirewall on, secrets on, HM on, o11y metrics on, zram swap, roleGroups: networkmanager/video/audio/docker
endpointLocked-downbase, operators, secrets, impermanenceSecrets on with user key enabled. Consumer provides firewall, HM, and hardware.
microvm-guestVM guestbase, operators, impermanenceMinimal - host owns firewall, backup, and networking

Disk Templates

Pre-built disko configurations for common partition layouts.

TemplateBootFilesystemImpermanence
btrfsUEFIbtrfsNo
btrfs-biosLegacy BIOSbtrfsNo
btrfs-impermanenceUEFIbtrfsYes
btrfs-impermanence-biosLegacy BIOSbtrfsYes
ext4UEFIext4No
luks-btrfs-impermanenceUEFILUKS + btrfsYes

Access via inputs.nixfleet-scopes.scopes.disk-templates.<name>.

What Belongs Where

ContentBelongs in
Framework API (mkHost)nixfleet
Service modules (agent, CP, cache, microvm)nixfleet
Infrastructure scopes and rolesnixfleet-scopes
Disk templatesnixfleet-scopes
Compliance controls and frameworksnixfleet-compliance
Opinionated fleet scopes (dev, graphical, theming)Your fleet repo
Hardware configs and dotfilesYour fleet repo