nixos/jool: validate the configuration

This checks the validity of both NAT64 and SIIT configurations
at build time. An error produces something like this:

    Validating Jool configuration... Error: Cannot parse '283.0.113.1' as an IPv4 address.
This commit is contained in:
rnhmjoj 2023-07-01 23:17:01 +02:00
parent 41934b580a
commit 1f28c8defc
No known key found for this signature in database
GPG key ID: BFBAF4C975F76450

View file

@ -201,6 +201,17 @@ in
} // hardening;
};
system.checks = lib.singleton (pkgs.runCommand "jool-validated" {
nativeBuildInputs = [ pkgs.buildPackages.jool-cli ];
preferLocalBuild = true;
} ''
printf 'Validating Jool configuration... '
${lib.optionalString cfg.siit.enable "jool_siit file check ${siitConf}"}
${lib.optionalString cfg.nat64.enable "jool file check ${nat64Conf}"}
printf 'ok\n'
touch "$out"
'');
networking.jool.nat64.config = mkDefaultAttrs defaultNat64;
networking.jool.siit.config = mkDefaultAttrs defaultSiit;