nix: check the policy at build time and the config before a switch

Store-path policy: check policy -f in system.checks.
Pre-switch: check all as the headscale user. Offline, no DB copy.

Fixes #2898
This commit is contained in:
Kristoffer Dalby committed 2026-11-07 21:25:44 +00:00
1 parent 66a50a1241
commit b6ba6e42ee
5 files changed
+306 -7

No files matched your search

+15 -3
View File
@@ -25,8 +25,19 @@
{
# NixOS module
nixosModules = rec {
# A path, so importing it twice (directly and via testkit) dedupes.
headscale = ./nix/module.nix;
# Defaults the package to this flake's: the pre-switch checks need
# `headscale check`. Priority 1001 sits just below mkDefault, so a
# user's mkDefault wins instead of conflicting. The overlay, not
# self.packages, so every system nixpkgs supports evaluates.
headscale =
{ lib, pkgs, ... }:
{
# Dedupes importing it twice, directly and via testkit.
key = "${toString ./flake.nix}#nixosModules.headscale";
_file = "${toString ./flake.nix}#nixosModules.headscale";
imports = [ ./nix/module.nix ];
services.headscale.package = lib.mkOverride 1001 (self.overlays.default pkgs pkgs).headscale;
};
default = headscale;
# Control node for NixOS VM tests of Tailscale clients, and a peer
# that joins it; nix/README.md.
@@ -308,11 +319,12 @@
);
# Gated to Linux: parts of the tree are Linux-specific, and the VM
# test needs KVM.
# tests need KVM.
checks = pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux (
goChecks
// {
headscale = pkgs.testers.runNixOSTest (import ./nix/tests/headscale.nix self);
headscale-checks = pkgs.testers.runNixOSTest (import ./nix/tests/checks.nix self);
}
);
}