Get initial zoneConfig generation working
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/result
|
||||
43
flake.nix
43
flake.nix
@@ -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;
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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
23
zones/pvv.ntnu.no.nix
Normal 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";
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user