infrastructure/meta/verify.nix

42 lines
1,001 B
Nix
Raw Normal View History

# SPDX-FileCopyrightText: 2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>
# SPDX-FileContributor: Maurice Debray <maurice.debray@dgnum.eu>
#
# SPDX-License-Identifier: EUPL-1.2
2024-03-13 11:24:27 +01:00
# Nix expression to check if meta module is evaluating correctly.
# To do so run `nix-build ./verify.nix`
2024-02-23 10:50:50 +01:00
let
sources = import ../npins;
pkgs = import sources.nixpkgs { };
2024-03-29 14:37:21 +01:00
dns = import sources."dns.nix" { inherit pkgs; };
2024-02-23 10:50:50 +01:00
in
2024-03-29 14:37:21 +01:00
{
2024-05-14 23:31:49 +02:00
meta =
let
config = (import ./.) pkgs.lib;
failed = builtins.map (x: "- ${x.message}") (builtins.filter (x: !x.assertion) config.assertions);
in
if (failed != [ ]) then
throw ''
2024-05-15 09:58:50 +02:00
2024-05-14 23:31:49 +02:00
Failed assertions:
${builtins.concatStringsSep "\n" failed}
''
else
pkgs.writers.writeJSON "meta.json" config;
2024-03-29 14:37:21 +01:00
dns = dns.util.writeZone "dgnum.eu" (
pkgs.lib.recursiveUpdate { SOA.serial = 0; } (
import ./dns.nix {
inherit dns;
lib = pkgs.lib // {
extra = import ../lib/nix-lib;
};
}
)
2024-03-29 14:37:21 +01:00
);
}