Switch to dns.nix
This commit is contained in:
parent
54c215c320
commit
e90f8e7ea6
37
flake.lock
37
flake.lock
|
@ -1,5 +1,41 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"dns-nix": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1703643450,
|
||||||
|
"narHash": "sha256-EUUF5oxFFPX/etKm0FNQg+7MPHQlNjmM1XhNgyDf7A0=",
|
||||||
|
"owner": "NickCao",
|
||||||
|
"repo": "dns.nix",
|
||||||
|
"rev": "70dcce71560d4253f63812fa36dee994c81ae814",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NickCao",
|
||||||
|
"repo": "dns.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1614513358,
|
||||||
|
"narHash": "sha256-LakhOx3S1dRjnh0b5Dg3mbZyH0ToC9I8Y2wKSkBaTzU=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "5466c5bbece17adaab2d82fae80b46e807611bf3",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1713475287,
|
"lastModified": 1713475287,
|
||||||
|
@ -55,6 +91,7 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"dns-nix": "dns-nix",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"openwrt": "openwrt",
|
"openwrt": "openwrt",
|
||||||
"openwrt-imagebuilder": "openwrt-imagebuilder"
|
"openwrt-imagebuilder": "openwrt-imagebuilder"
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
description = "Zentralwerk network";
|
description = "Zentralwerk network";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
|
dns-nix = {
|
||||||
|
url = "github:NickCao/dns.nix";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
nixpkgs.url = "github:SuperSandro2000/nixpkgs/nixos-23.11";
|
nixpkgs.url = "github:SuperSandro2000/nixpkgs/nixos-23.11";
|
||||||
openwrt = {
|
openwrt = {
|
||||||
url = "git+https://git.openwrt.org/openwrt/openwrt.git?ref=openwrt-23.05";
|
url = "git+https://git.openwrt.org/openwrt/openwrt.git?ref=openwrt-23.05";
|
||||||
|
@ -13,7 +17,7 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = inputs@{ self, nixpkgs, openwrt, openwrt-imagebuilder }:
|
outputs = inputs@{ self, dns-nix, nixpkgs, openwrt, openwrt-imagebuilder }:
|
||||||
let
|
let
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
systems = [ system ];
|
systems = [ system ];
|
||||||
|
@ -26,7 +30,7 @@
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
hostName = name;
|
hostName = name;
|
||||||
inherit (self) lib;
|
inherit (self) lib;
|
||||||
inherit inputs self;
|
inherit inputs dns-nix self;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
{ hostName, config, lib, pkgs, self, ... }:
|
{ config, dns-nix, hostName, lib, pkgs, self, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
serial = builtins.substring 0 10 self.lastModifiedDate;
|
serial = builtins.substring 0 10 self.lastModifiedDate;
|
||||||
|
|
||||||
generateZoneFile = { name, ns, records, dynamic }:
|
generateZoneFile = let
|
||||||
builtins.toFile "${name}.zone" ''
|
util = dns-nix.util.${pkgs.system};
|
||||||
$ORIGIN ${name}.
|
in { name, ns, records, ... }: util.writeZone name (with dns-nix.lib.combinators; {
|
||||||
$TTL 1h
|
TTL = 60*60;
|
||||||
|
SOA = {
|
||||||
@ IN SOA ${lib.dns.ns}. astro.spaceboyz.net. (
|
nameServer = lib.dns.ns;
|
||||||
${serial} ; serial
|
adminEmail = "astro@spaceboyz.net";
|
||||||
1h ; refresh
|
serial = lib.toInt serial;
|
||||||
1m ; retry
|
refresh = 60*60;
|
||||||
2h ; expire
|
retry = 60;
|
||||||
1m ; minimum
|
expire = 2*60;
|
||||||
)
|
minimum = 60;
|
||||||
${lib.concatMapStrings (ns: " IN NS ${ns}.\n") ns}
|
};
|
||||||
|
NS = ns;
|
||||||
${lib.concatMapStrings ({ name, type, data }:
|
subdomains = lib.head (map ({ name, type, data }: {
|
||||||
"${name} IN ${type} ${data}\n"
|
${name}.${type} = [ data ];
|
||||||
) records}
|
}) records ++ [ { } ]);
|
||||||
'';
|
});
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options =
|
options =
|
||||||
|
|
Loading…
Reference in New Issue