change nix schema

This commit is contained in:
satr14washere 2026-03-22 07:15:41 +07:00
commit be1ebe0d15
32 changed files with 238 additions and 344 deletions

View file

@ -1,13 +1,10 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "satr14washere";
email = "admin@satr14.my.id";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
A = [
{
address = "203.0.113.1";
@ -16,13 +13,10 @@ with dns.lib.combinators;
"203.0.113.2"
(ttl (60 * 60) (a "203.0.113.3"))
];
AAAA = [
"4321:0:1:2:3:4:567:89ab"
];
MX = mx.google;
TXT = [
(
with spf;
@ -32,11 +26,9 @@ with dns.lib.combinators;
]
)
];
CNAME = [ "example.com." ];
DMARC = [ (dmarc.postmarkapp "mailto:re+abcdefghijk@dmarc.postmarkapp.com") ];
CAA = letsEncrypt "admin@example.com";
SRV = [
{
service = "sip";
@ -45,34 +37,6 @@ with dns.lib.combinators;
target = "sip.example.com";
}
];
SSHFP = [
{
algorithm = "ed25519";
fingerprintType = "sha256";
fingerprint = "899EB4AC9285578AFDA3CCBE152EE78D8618B8F3862FEF2703E1FC7011E9B8AA";
}
];
OPENPGPKEY = [
"very long base64 text"
];
HTTPS = [
{
svcPriority = 1;
targetName = ".";
alpn = [
"http/1.1"
"h2"
"h3"
];
ipv4hint = [
"203.0.113.1"
"203.0.113.2"
"203.0.113.3"
];
ipv6hint = [ "4321:0:1:2:3:4:567:89ab" ];
}
];
TLSA = [
{
certUsage = "dane-ee";
@ -81,18 +45,5 @@ with dns.lib.combinators;
certificate = "899EB4AC9285578AFDA3CCBE152EE78D8618B8F3862FEF2703E1FC7011E9B8AA";
}
];
subdomains = rec {
www.A = [ "203.0.113.4" ];
www2 = host "203.0.113.5" "4321:0:1:2:3:4:567:89bb";
www3 = host "203.0.113.6" null;
www4 = www3;
staging = delegateTo [
"ns1.another.com."
"ns2.another.com."
];
foo.subdomains.www.CNAME = [ "foo.test.com." ];
};
}

View file

@ -1,12 +1,10 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "ColinLeDev";
};
description = "Discord verification";
proxy = false;
in
with dns.lib.combinators;
{
records = {
TXT = [ "dh=279643a6f8677dedb1c5c63d007fc4516149679c" ];
};
}

View file

@ -1,13 +1,11 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "CuteDog5695";
email = "cutedog5695@gmail.com";
repo = "https://github.com/CuteDog5695/cutedog5695.github.io";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
TXT = [ "dh=a7c19efb0f6bc38b97a33760f6c1ee84df4151b1" ];
};
}

View file

@ -1,13 +1,11 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "JustDeveloper1";
email = "justdeveloper@juststudio.is-a.dev";
repo = "https://github.com/JustDeveloper1/Website";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
TXT = [ "dh=6024027bc233825451e290ac37a4b4a1f838ee70" ];
};
}

View file

@ -1,11 +1,9 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "satr14washere";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
TXT = [ "dh=d509fc9014e196311ed887c2e410cdefa833436e" ];
};
}

View file

@ -1,11 +1,9 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "Roki100";
discord = "289479495444987904";
};
in
with dns.lib.combinators;
{
records = {
TXT = [ "dh=5633078cd5bfd347a896ddb0f0de017c5423aa06" ];
};
}

View file

@ -1,11 +1,9 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "shadowe1ite";
};
proxy = true;
in
with dns.lib.combinators;
{
records = {
CNAME = [ "shadowe1ite.github.io." ];
};
}

View file

@ -1,12 +1,10 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "orangci";
email = "c@orangc.xyz";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
CNAME = [ "edge.redirect.pizza." ];
};
}

View file

@ -1,12 +1,10 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "ColinLeDev";
};
description = "My personal portfolio hosted on my server";
proxy = false;
in
with dns.lib.combinators;
{
records = {
CNAME = [ "proxy.col1n.fr." ];
};
}

View file

@ -1,13 +1,11 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "CuteDog5695";
email = "cutedog5695@gmail.com";
repo = "https://github.com/CuteDog5695/cutedog5695.github.io";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
CNAME = [ "edge.redirect.pizza." ];
};
}

View file

@ -1,10 +1,8 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "elkhaff";
};
in
with dns.lib.combinators;
{
records = {
CNAME = [ "portofolio-pixel.pages.dev." ];
};
}

View file

@ -1,13 +1,11 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "JustDeveloper1";
email = "support@juststudio.is-a.dev";
repo = "https://github.com/JustStudio7/Website";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
CNAME = [ "edge.redirect.pizza." ];
};
}

View file

@ -1,11 +1,9 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "jacobrdale";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
CNAME = [ "hexon404.onrender.com." ];
};
}

View file

@ -1,13 +1,11 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "JustDeveloper1";
email = "justdeveloper@juststudio.is-a.dev";
repo = "https://github.com/JustDeveloper1/Website";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
CNAME = [ "edge.redirect.pizza." ];
};
}

View file

@ -1,11 +1,9 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "FWEEaaaa1";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
A = [ "128.204.223.115" ];
};
}

View file

@ -1,13 +1,10 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "joestr";
email = "strasser999@gmail.com";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
A = [ "142.132.173.34" ];
AAAA = [ "2a01:4f8:1c0c:6cc0::1" ];
MX = [
@ -16,4 +13,5 @@ with dns.lib.combinators;
preference = 10;
}
];
};
}

View file

@ -1,13 +1,11 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "JustDeveloper1";
email = "support@juststudio.is-a.dev";
repo = "https://github.com/JustStudio7/Website";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
CNAME = [ "edge.redirect.pizza." ];
};
}

View file

@ -1,13 +1,11 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "JustDeveloper1";
email = "justdeveloper@juststudio.is-a.dev";
repo = "https://github.com/JustDeveloper1/Website";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
CNAME = [ "edge.redirect.pizza." ];
};
}

View file

@ -1,13 +1,11 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "JustDeveloper1";
email = "justdeveloper@juststudio.is-a.dev";
repo = "https://github.com/JustDeveloper1/Website";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
CNAME = [ "edge.redirect.pizza." ];
};
}

View file

@ -1,13 +1,11 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "JustDeveloper1";
email = "justdeveloper@juststudio.is-a.dev";
repo = "https://github.com/JustDeveloper1/Website";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
CNAME = [ "edge.redirect.pizza." ];
};
}

View file

@ -1,13 +1,11 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "JustDeveloper1";
email = "support@juststudio.is-a.dev";
repo = "https://github.com/JustStudio7/Website";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
CNAME = [ "edge.redirect.pizza." ];
};
}

View file

@ -1,11 +1,9 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "Bananalolok";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
A = [ "69.197.135.205" ];
};
}

View file

@ -1,12 +1,10 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "EducatedSuddenBucket";
email = "me@esb.is-a.dev";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
CNAME = [ "educatedsuddenbucket-github-io.onrender.com." ];
};
}

View file

@ -1,11 +1,9 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "heypxl";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
CNAME = [ "heypxl.github.io." ];
};
}

View file

@ -1,11 +1,9 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "vortexprime24";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
CNAME = [ "fire.hackclub.app." ];
};
}

View file

@ -1,12 +1,10 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "Roki100";
discord = "289479495444987904";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
CNAME = [ "edge.redirect.pizza." ];
};
}

View file

@ -1,10 +1,8 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "satr14washere";
};
in
with dns.lib.combinators;
{
records = {
CNAME = [ "5th-site.pages.dev." ];
};
}

View file

@ -1,12 +1,10 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "Stef-00012";
email = "admin@stefdp.lol";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
CNAME = [ "proxy.stefdp.lol." ];
};
}

View file

@ -1,13 +1,11 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "ukriu";
email = "partofmyid@ukriu.com";
};
description = "my website";
proxy = false;
in
with dns.lib.combinators;
{
records = {
CNAME = [ "ukriu.pages.dev." ];
};
}

View file

@ -1,12 +1,10 @@
{ dns, ... }:
let
{ dns, ... }: with dns.lib.combinators; {
owner = {
username = "Stef-00012";
email = "admin@stefdp.com";
};
proxy = false;
in
with dns.lib.combinators;
{
records = {
CNAME = [ "proxy.stefdp.com." ];
};
}

View file

@ -24,7 +24,7 @@
in
{
name = key;
value = import (./domains + "/${name}") { inherit dns; };
value = (import (./domains + "/${name}") { inherit dns; }).records;
}
) domainFiles;
in
@ -41,6 +41,7 @@
};
NS = domain.nameservers;
# note: Cloudflare ignores SOA and NS records uploaded via Zone File, they are included just so that dns.nix builds a valid zone file.
CNAME = [ "website-e7n.pages.dev." ];
inherit subdomains;
}
)

View file

@ -6,7 +6,7 @@ Reads each JSON domain config and generates a corresponding .nix file
following the format from docs/example.nix.
Usage:
python3 scripts/migrate-json-to-nix.py [--dry-run] [--delete-json]
python3 scripts/migrate-nix.py [--dry-run] [--delete-json]
Options:
--dry-run Print generated .nix content to stdout without writing files
@ -15,7 +15,6 @@ Options:
import json
import sys
import os
from pathlib import Path
DOMAINS_DIR = Path(__file__).resolve().parent.parent / "domains"
@ -31,37 +30,36 @@ def json_to_nix(data: dict) -> str:
lines = []
# Header
lines.append("{ dns, ... }: let")
# Owner block
owner_lines = []
if owner.get("username"):
owner_lines.append(f' username = "{owner["username"]}";')
if owner.get("email"):
owner_lines.append(f' email = "{owner["email"]}";')
if owner.get("discord"):
owner_lines.append(f' discord = "{owner["discord"]}";')
if owner.get("repo"):
owner_lines.append(f' repo = "{owner["repo"]}";')
# Header — no let block, just the function head with `with`
lines.append("{ dns, ... }: with dns.lib.combinators; {")
# Owner block as a top-level attribute
lines.append(" owner = {")
for ol in owner_lines:
lines.append(ol)
if owner.get("username"):
lines.append(f' username = "{escape_nix_string(owner["username"])}";')
if owner.get("email"):
lines.append(f' email = "{escape_nix_string(owner["email"])}";')
if owner.get("discord"):
lines.append(f' discord = "{escape_nix_string(owner["discord"])}";')
if owner.get("repo"):
lines.append(f' repo = "{escape_nix_string(owner["repo"])}";')
lines.append(" };")
# Description as a top-level attribute
if description is not None:
lines.append(f' description = "{escape_nix_string(description)}";')
# Proxy as a top-level attribute
if proxy is not None:
lines.append(f" proxy = {'true' if proxy else 'false'};")
lines.append("in with dns.lib.combinators; {")
# Records
# Records nested under `records`
record_lines = build_record_lines(record)
if record_lines:
lines.append(" records = {")
for rl in record_lines:
lines.append(rl)
lines.append(" };")
lines.append("}")
lines.append("")
@ -78,7 +76,10 @@ def escape_nix_string(s: str) -> str:
def build_record_lines(record: dict) -> list[str]:
"""Build the Nix record lines from the JSON record dict."""
"""Build the Nix record lines from the JSON record dict.
These are indented with 4 spaces since they sit inside `records = { ... };`.
"""
lines = []
if "A" in record:
@ -111,21 +112,20 @@ def build_record_lines(record: dict) -> list[str]:
value = record["CNAME"]
if isinstance(value, list):
value = value[0]
lines.append(f' CNAME = [ "{value}." ];')
lines.append(f' CNAME = [ "{ensure_fqdn(value)}" ];')
if "ALIAS" in record:
value = record["ALIAS"]
if isinstance(value, list):
value = value[0]
# ALIAS is typically handled as CNAME in dns.nix
lines.append(f' CNAME = [ "{value}." ];')
lines.append(f' CNAME = [ "{ensure_fqdn(value)}" ];')
if "MX" in record:
values = record["MX"]
if isinstance(values, list):
lines.append(" MX = [")
for i, v in enumerate(values):
# MX records need priority; default to (i+1)*10
priority = (i + 1) * 10
lines.append(" {")
lines.append(f' exchange = "{ensure_fqdn(v)}";')