flake.nix: add checks, add checkPhases with nsd-check* tests

This commit is contained in:
2026-05-25 16:02:42 +09:00
parent 8acff15072
commit f604e300ed
3 changed files with 31 additions and 7 deletions
+7 -2
View File
@@ -11,7 +11,7 @@
};
outputs =
{ nixpkgs, dns, ... }@inputs:
{ self, nixpkgs, dns, ... }@inputs:
let
inherit (nixpkgs) lib;
systems = [
@@ -27,7 +27,7 @@
inherit dns;
};
nsdConfig = pkgs.callPackage ./nsd.conf.nix { inherit pkgs; };
nsdConfig = pkgs.callPackage ./nsd.conf.nix { };
default = pkgs.runCommand "pvv-dns" { } ''
mkdir -p $out/zones
@@ -37,5 +37,10 @@
cp -r ${nsdConfig} $out/etc/nsd/nsd.conf
'';
});
checks = forAllSystems (system: _: rec {
zoneFiles = self.packages.${system}.zoneFiles.overrideAttrs { doCheck = true; };
nsdConfig = self.packages.${system}.nsdConfig.override { doCheck = true; };
});
};
}
+13 -5
View File
@@ -1,9 +1,15 @@
{ pkgs, ... }:
{
lib,
writeTextFile,
doCheck ? false,
nsd,
}:
let
sourceIP = "129.241.210.211"; # dvask.pvv.ntnu.no
in
pkgs.writeText "nsd.conf" (
''
writeTextFile {
name = "nsd.conf";
text = ''
# Generated by https://git.pvv.ntnu.no/felixalb/PVV-DNS
# See man 5 nsd.conf
@@ -56,5 +62,7 @@ pkgs.writeText "nsd.conf" (
"pvv.ntnu.no"
"pvv.org"
]
))
)
));
checkPhase = lib.optionalString doCheck "${lib.getExe' nsd "nsd-checkconf"} $target";
}
+11
View File
@@ -4,6 +4,7 @@
stdenvNoCC,
writeText,
nsd,
}:
let
@@ -33,4 +34,14 @@ stdenvNoCC.mkDerivation {
mkdir -p $out
''
+ (lib.concatMapAttrsStringSep "\n" (name: path: "cp ${path} $out/${name}.zone") zoneConfigs);
doCheck = false;
nativeCheckInputs = [ nsd ];
checkPhase = ''
runHook preCheck
${lib.concatMapAttrsStringSep "\n" (name: zonefile: "nsd-checkzone '${name}' '${zonefile}'") zoneConfigs}
runHook postCheck
'';
}