Add nix flake checks #2

Merged
oysteikt merged 3 commits from add-nix-flake-check into main 2026-05-25 19:25:18 +02:00
3 changed files with 66 additions and 25 deletions
+19 -20
View File
@@ -11,7 +11,7 @@
};
outputs =
{ nixpkgs, dns, ... }@inputs:
{ self, nixpkgs, dns, ... }@inputs:
let
inherit (nixpkgs) lib;
systems = [
@@ -19,29 +19,28 @@
"aarch64-linux"
"aarch64-darwin"
];
forAllSystems = f: lib.genAttrs systems f;
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system nixpkgs.legacyPackages.${system});
in
{
packages = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
rec {
zoneFiles = pkgs.callPackage ./zoneConfig.nix {
inherit dns;
};
packages = forAllSystems (system: pkgs: rec {
zoneFiles = pkgs.callPackage ./zoneConfig.nix {
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
mkdir -p $out/etc/nsd
default = pkgs.runCommand "pvv-dns" { } ''
mkdir -p $out/zones
mkdir -p $out/etc/nsd
cp -r ${zoneFiles}/* $out/zones/
cp -r ${nsdConfig} $out/etc/nsd/nsd.conf
'';
}
);
cp -r ${zoneFiles}/* $out/zones/
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.overrideAttrs { doCheck = true; };
});
};
}
+36 -5
View File
@@ -1,9 +1,19 @@
{ pkgs, ... }:
{
lib,
stdenvNoCC,
nsd,
}:
let
sourceIP = "129.241.210.211"; # dvask.pvv.ntnu.no
in
pkgs.writeText "nsd.conf" (
''
stdenvNoCC.mkDerivation {
name = "nsd.conf";
dontUnpack = true;
dontBuild = true;
passAsFile = [ "configFile" ];
configFile = ''
# Generated by https://git.pvv.ntnu.no/felixalb/PVV-DNS
# See man 5 nsd.conf
@@ -56,5 +66,26 @@ pkgs.writeText "nsd.conf" (
"pvv.ntnu.no"
"pvv.org"
]
))
)
));
doCheck = false;
nativeCheckInputs = [ nsd ];
checkPhase = ''
runHook preCheck
nsd-checkconf "$configFilePath"
echo 'nsd.conf is ok'
runHook postCheck
'';
installPhase = ''
runHook preCheck
install -Dm444 "$configFilePath" "$out"
runHook postCheck
'';
doFixup = false;
}
+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
'';
}