Get initial zoneConfig generation working

This commit is contained in:
2025-03-06 20:54:15 +01:00
parent 7cd1b27cfc
commit 2c4ce18004
4 changed files with 66 additions and 22 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/result

View File

@@ -6,22 +6,29 @@
dns.url = "github:nix-community/dns.nix";
};
outputs = { nixpkgs, dns, ... }@inputs:
let
inherit (nixpkgs) lib;
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
forAllSystems = f: lib.genAttrs systems f;
in {
packages = forAllSystems (system: rec {
zoneConfig = nixpkgs.legacyPackages.${system}.callPackage ./zoneConfig.nix {
inherit dns;
};
default = zoneConfig;
});
};
outputs =
{ nixpkgs, dns, ... }@inputs:
let
inherit (nixpkgs) lib;
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
forAllSystems = f: lib.genAttrs systems f;
in
{
packages = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
rec {
zoneConfig = pkgs.callPackage ./zoneConfig.nix {
inherit dns;
};
default = zoneConfig;
}
);
};
}

View File

@@ -1,14 +1,27 @@
{
lib,
stdenvNoCC,
dns,
stdenvNoCC,
writeText,
}:
let
zoneConfigs =
lib.mapAttrs
(name: path: writeText "${name}.zone" (dns.lib.toString name (import path { inherit dns; })))
{
"pvv.ntnu.no" = ./zones/pvv.ntnu.no.nix;
};
in
stdenvNoCC.mkDerivation {
name = "zoneConfig";
dontUnpack = true;
installPhase = ''
mkdir $out
'';
installPhase =
''
mkdir -p $out/zones
''
+ (lib.concatMapAttrsStringSep "\n" (name: path: "cp ${path} $out/zones/${name}.zone") zoneConfigs);
}

23
zones/pvv.ntnu.no.nix Normal file
View File

@@ -0,0 +1,23 @@
{ dns, ... }:
with dns.lib.combinators;
{
SOA = {
nameServer = "ns1.pvv.ntnu.no";
adminEmail = "drift@pvv.ntnu.no";
serial = 2025021701; # TODO: Automate
};
NS = [
"ns1.pvv.ntnu.no"
"ns2.pvv.ntnu.no"
];
CNAME = [ "www.pvv.ntnu.no" ];
subdomains = rec {
foobar = host "203.0.113.2" "4321:0:1:2:3:4:567:89bb";
ns1 = foobar;
ns2 = host "203.0.113.3" "4321:0:1:2:3:4:567:89cc";
};
}