aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--modules/by-name/ma/mail/module.nix71
-rw-r--r--modules/by-name/ns/nsd/dns/default.nix (renamed from modules/by-name/dn/dns/dns/default.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/default.nix (renamed from modules/by-name/dn/dns/dns/types/default.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/record.nix (renamed from modules/by-name/dn/dns/dns/types/record.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/A.nix (renamed from modules/by-name/dn/dns/dns/types/records/A.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/AAAA.nix (renamed from modules/by-name/dn/dns/dns/types/records/AAAA.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/CAA.nix (renamed from modules/by-name/dn/dns/dns/types/records/CAA.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/CNAME.nix (renamed from modules/by-name/dn/dns/dns/types/records/CNAME.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/DKIM.nix (renamed from modules/by-name/dn/dns/dns/types/records/DKIM.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/DMARC.nix (renamed from modules/by-name/dn/dns/dns/types/records/DMARC.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/DNAME.nix (renamed from modules/by-name/dn/dns/dns/types/records/DNAME.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/DNSKEY.nix (renamed from modules/by-name/dn/dns/dns/types/records/DNSKEY.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/DS.nix (renamed from modules/by-name/dn/dns/dns/types/records/DS.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/HTTPS.nix (renamed from modules/by-name/dn/dns/dns/types/records/HTTPS.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/MTA-STS.nix (renamed from modules/by-name/dn/dns/dns/types/records/MTA-STS.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/MX.nix (renamed from modules/by-name/dn/dns/dns/types/records/MX.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/NS.nix (renamed from modules/by-name/dn/dns/dns/types/records/NS.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/OPENPGPKEY.nix (renamed from modules/by-name/dn/dns/dns/types/records/OPENPGPKEY.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/PTR.nix (renamed from modules/by-name/dn/dns/dns/types/records/PTR.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/SOA.nix (renamed from modules/by-name/dn/dns/dns/types/records/SOA.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/SRV.nix (renamed from modules/by-name/dn/dns/dns/types/records/SRV.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/SSHFP.nix (renamed from modules/by-name/dn/dns/dns/types/records/SSHFP.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/SVCB.nix (renamed from modules/by-name/dn/dns/dns/types/records/SVCB.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/TLSA.nix (renamed from modules/by-name/dn/dns/dns/types/records/TLSA.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/TXT.nix (renamed from modules/by-name/dn/dns/dns/types/records/TXT.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/default.nix (renamed from modules/by-name/dn/dns/dns/types/records/default.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/records/dnssec.nix (renamed from modules/by-name/dn/dns/dns/types/records/dnssec.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/simple.nix (renamed from modules/by-name/dn/dns/dns/types/simple.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/types/zone.nix (renamed from modules/by-name/dn/dns/dns/types/zone.nix)0
-rw-r--r--modules/by-name/ns/nsd/dns/util/default.nix (renamed from modules/by-name/dn/dns/dns/util/default.nix)0
-rw-r--r--modules/by-name/ns/nsd/module.nix (renamed from modules/by-name/dn/dns/module.nix)45
-rw-r--r--modules/by-name/un/unbound/module.nix64
-rw-r--r--modules/common/vhack/default.nix21
33 files changed, 129 insertions, 72 deletions
diff --git a/modules/by-name/ma/mail/module.nix b/modules/by-name/ma/mail/module.nix
index f0c62d7..93c37bc 100644
--- a/modules/by-name/ma/mail/module.nix
+++ b/modules/by-name/ma/mail/module.nix
@@ -267,40 +267,45 @@ in {
};
config = lib.mkIf cfg.enable {
- vhack.persist.directories = [
- {
- directory = "/var/lib/mail/vmail";
- user = "virtualMail";
- group = "virtualMail";
- mode = "0700";
- }
- {
- directory = "/var/lib/mail/dkim";
- user = "opendkim";
- group = "opendkim";
- mode = "0700";
- }
- {
- directory = "/var/lib/postfix/data";
- user = "postfix";
- group = "postfix";
- mode = "0700";
- }
- {
- directory = "/var/lib/postfix/queue";
- user = "postfix";
- group = "postfix";
- mode = "0700";
- }
- {
- directory = "/var/lib/rspamd";
- user = "rspamd";
- group = "rspamd";
- mode = "0700";
- }
- ];
+ vhack = {
+ persist.directories = [
+ {
+ directory = "/var/lib/mail/vmail";
+ user = "virtualMail";
+ group = "virtualMail";
+ mode = "0700";
+ }
+ {
+ directory = "/var/lib/mail/dkim";
+ user = "opendkim";
+ group = "opendkim";
+ mode = "0700";
+ }
+ {
+ directory = "/var/lib/postfix/data";
+ user = "postfix";
+ group = "postfix";
+ mode = "0700";
+ }
+ {
+ directory = "/var/lib/postfix/queue";
+ user = "postfix";
+ group = "postfix";
+ mode = "0700";
+ }
+ {
+ directory = "/var/lib/rspamd";
+ user = "rspamd";
+ group = "rspamd";
+ mode = "0700";
+ }
+ ];
+
+ # For DNSSEC we need to have it.
+ unbound.enable = true;
- vhack.nginx.enable = true;
+ nginx.enable = true;
+ };
services.nginx.virtualHosts = {
"${cfg.fqdn}" = {
diff --git a/modules/by-name/dn/dns/dns/default.nix b/modules/by-name/ns/nsd/dns/default.nix
index 4ce07d8..4ce07d8 100644
--- a/modules/by-name/dn/dns/dns/default.nix
+++ b/modules/by-name/ns/nsd/dns/default.nix
diff --git a/modules/by-name/dn/dns/dns/types/default.nix b/modules/by-name/ns/nsd/dns/types/default.nix
index ece315f..ece315f 100644
--- a/modules/by-name/dn/dns/dns/types/default.nix
+++ b/modules/by-name/ns/nsd/dns/types/default.nix
diff --git a/modules/by-name/dn/dns/dns/types/record.nix b/modules/by-name/ns/nsd/dns/types/record.nix
index e992bf9..e992bf9 100644
--- a/modules/by-name/dn/dns/dns/types/record.nix
+++ b/modules/by-name/ns/nsd/dns/types/record.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/A.nix b/modules/by-name/ns/nsd/dns/types/records/A.nix
index 296943e..296943e 100644
--- a/modules/by-name/dn/dns/dns/types/records/A.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/A.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/AAAA.nix b/modules/by-name/ns/nsd/dns/types/records/AAAA.nix
index 4717176..4717176 100644
--- a/modules/by-name/dn/dns/dns/types/records/AAAA.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/AAAA.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/CAA.nix b/modules/by-name/ns/nsd/dns/types/records/CAA.nix
index 4b40510..4b40510 100644
--- a/modules/by-name/dn/dns/dns/types/records/CAA.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/CAA.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/CNAME.nix b/modules/by-name/ns/nsd/dns/types/records/CNAME.nix
index 095b078..095b078 100644
--- a/modules/by-name/dn/dns/dns/types/records/CNAME.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/CNAME.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/DKIM.nix b/modules/by-name/ns/nsd/dns/types/records/DKIM.nix
index 31b2f67..31b2f67 100644
--- a/modules/by-name/dn/dns/dns/types/records/DKIM.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/DKIM.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/DMARC.nix b/modules/by-name/ns/nsd/dns/types/records/DMARC.nix
index 0f10f2c..0f10f2c 100644
--- a/modules/by-name/dn/dns/dns/types/records/DMARC.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/DMARC.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/DNAME.nix b/modules/by-name/ns/nsd/dns/types/records/DNAME.nix
index 042ce95..042ce95 100644
--- a/modules/by-name/dn/dns/dns/types/records/DNAME.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/DNAME.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/DNSKEY.nix b/modules/by-name/ns/nsd/dns/types/records/DNSKEY.nix
index 86ce3a1..86ce3a1 100644
--- a/modules/by-name/dn/dns/dns/types/records/DNSKEY.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/DNSKEY.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/DS.nix b/modules/by-name/ns/nsd/dns/types/records/DS.nix
index 76fac9a..76fac9a 100644
--- a/modules/by-name/dn/dns/dns/types/records/DS.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/DS.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/HTTPS.nix b/modules/by-name/ns/nsd/dns/types/records/HTTPS.nix
index 6e2ef3d..6e2ef3d 100644
--- a/modules/by-name/dn/dns/dns/types/records/HTTPS.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/HTTPS.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/MTA-STS.nix b/modules/by-name/ns/nsd/dns/types/records/MTA-STS.nix
index 030490e..030490e 100644
--- a/modules/by-name/dn/dns/dns/types/records/MTA-STS.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/MTA-STS.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/MX.nix b/modules/by-name/ns/nsd/dns/types/records/MX.nix
index c25b89c..c25b89c 100644
--- a/modules/by-name/dn/dns/dns/types/records/MX.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/MX.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/NS.nix b/modules/by-name/ns/nsd/dns/types/records/NS.nix
index ea60a91..ea60a91 100644
--- a/modules/by-name/dn/dns/dns/types/records/NS.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/NS.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/OPENPGPKEY.nix b/modules/by-name/ns/nsd/dns/types/records/OPENPGPKEY.nix
index 1f39cb9..1f39cb9 100644
--- a/modules/by-name/dn/dns/dns/types/records/OPENPGPKEY.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/OPENPGPKEY.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/PTR.nix b/modules/by-name/ns/nsd/dns/types/records/PTR.nix
index 075f82e..075f82e 100644
--- a/modules/by-name/dn/dns/dns/types/records/PTR.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/PTR.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/SOA.nix b/modules/by-name/ns/nsd/dns/types/records/SOA.nix
index db7436e..db7436e 100644
--- a/modules/by-name/dn/dns/dns/types/records/SOA.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/SOA.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/SRV.nix b/modules/by-name/ns/nsd/dns/types/records/SRV.nix
index 5f558ed..5f558ed 100644
--- a/modules/by-name/dn/dns/dns/types/records/SRV.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/SRV.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/SSHFP.nix b/modules/by-name/ns/nsd/dns/types/records/SSHFP.nix
index 1409860..1409860 100644
--- a/modules/by-name/dn/dns/dns/types/records/SSHFP.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/SSHFP.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/SVCB.nix b/modules/by-name/ns/nsd/dns/types/records/SVCB.nix
index 62cbc3d..62cbc3d 100644
--- a/modules/by-name/dn/dns/dns/types/records/SVCB.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/SVCB.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/TLSA.nix b/modules/by-name/ns/nsd/dns/types/records/TLSA.nix
index d92a29b..d92a29b 100644
--- a/modules/by-name/dn/dns/dns/types/records/TLSA.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/TLSA.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/TXT.nix b/modules/by-name/ns/nsd/dns/types/records/TXT.nix
index d605ce8..d605ce8 100644
--- a/modules/by-name/dn/dns/dns/types/records/TXT.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/TXT.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/default.nix b/modules/by-name/ns/nsd/dns/types/records/default.nix
index 76a86cd..76a86cd 100644
--- a/modules/by-name/dn/dns/dns/types/records/default.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/default.nix
diff --git a/modules/by-name/dn/dns/dns/types/records/dnssec.nix b/modules/by-name/ns/nsd/dns/types/records/dnssec.nix
index 648f676..648f676 100644
--- a/modules/by-name/dn/dns/dns/types/records/dnssec.nix
+++ b/modules/by-name/ns/nsd/dns/types/records/dnssec.nix
diff --git a/modules/by-name/dn/dns/dns/types/simple.nix b/modules/by-name/ns/nsd/dns/types/simple.nix
index fece2c9..fece2c9 100644
--- a/modules/by-name/dn/dns/dns/types/simple.nix
+++ b/modules/by-name/ns/nsd/dns/types/simple.nix
diff --git a/modules/by-name/dn/dns/dns/types/zone.nix b/modules/by-name/ns/nsd/dns/types/zone.nix
index 44ccb15..44ccb15 100644
--- a/modules/by-name/dn/dns/dns/types/zone.nix
+++ b/modules/by-name/ns/nsd/dns/types/zone.nix
diff --git a/modules/by-name/dn/dns/dns/util/default.nix b/modules/by-name/ns/nsd/dns/util/default.nix
index 59e661d..59e661d 100644
--- a/modules/by-name/dn/dns/dns/util/default.nix
+++ b/modules/by-name/ns/nsd/dns/util/default.nix
diff --git a/modules/by-name/dn/dns/module.nix b/modules/by-name/ns/nsd/module.nix
index c429bba..816cc7a 100644
--- a/modules/by-name/dn/dns/module.nix
+++ b/modules/by-name/ns/nsd/module.nix
@@ -3,7 +3,7 @@
lib,
...
}: let
- cfg = config.vhack.dns;
+ cfg = config.vhack.nsd;
localInterface = "127.0.0.1@5353";
@@ -47,8 +47,8 @@
in
lib.unique (parsePorts cfg.interfaces);
in {
- options.vhack.dns = {
- enable = lib.mkEnableOption "custom dns server";
+ options.vhack.nsd = {
+ enable = lib.mkEnableOption "nsd, a authoritative dns server";
openFirewall = lib.mkOption {
type = lib.types.bool;
@@ -79,34 +79,11 @@ in {
};
config = lib.mkIf cfg.enable {
- vhack.persist.directories = [
- {
- directory = "/var/lib/unbound";
- user = "unbound";
- group = "unbound";
- mode = "0700";
- }
- ];
-
- # Use unbound for resolving all local DNS queries.
- # unbounds also has the upside to verify DNSSEC.
services.unbound = {
- enable = true;
- stateDir = "/var/lib/unbound";
- resolveLocalQueries = true;
settings = {
server = {
+ # Otherwise, unbound will never ask the local nsd via the stub zones.
do-not-query-localhost = false;
-
- hide-identity = true;
- hide-version = true;
- harden-glue = true;
- harden-dnssec-stripped = true;
- # 0x20-encoded randomization
- use-caps-for-id = true;
-
- # DNSSEC - enabled by default with auto-trust-anchor-file
- # auto-trust-anchor-file = "/var/lib/unbound/root.key";
};
# Forward queries for in our zones to the local nsd.
@@ -119,12 +96,12 @@ in {
};
};
- # Use nsd to serve our own zone files, with the configured NS record pointing to the
- # servers ip address.
services.nsd = {
enable = true;
verbosity = 4;
- interfaces = [localInterface] ++ cfg.interfaces;
+ interfaces =
+ (lib.lists.optionals config.vhack.unbound.enable [localInterface])
+ ++ cfg.interfaces;
inherit zones;
};
@@ -140,13 +117,5 @@ in {
"network-online.target"
];
};
- users = {
- users = {
- "unbound".uid = config.vhack.constants.ids.uids.unbound;
- };
- groups = {
- "unbound".gid = config.vhack.constants.ids.gids.unbound;
- };
- };
};
}
diff --git a/modules/by-name/un/unbound/module.nix b/modules/by-name/un/unbound/module.nix
new file mode 100644
index 0000000..5fb3cbe
--- /dev/null
+++ b/modules/by-name/un/unbound/module.nix
@@ -0,0 +1,64 @@
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+{
+ lib,
+ config,
+ pkgs,
+ ...
+}: let
+ cfg = config.vhack.unbound;
+in {
+ options.vhack.unbound = {
+ enable = lib.mkEnableOption "local unbound, a resolving dns server";
+ };
+
+ config = lib.mkIf cfg.enable {
+ vhack.persist.directories = [
+ {
+ directory = "/var/lib/unbound";
+ user = "unbound";
+ group = "unbound";
+ mode = "0700";
+ }
+ ];
+
+ services.unbound = {
+ enable = true;
+ stateDir = "/var/lib/unbound";
+ resolveLocalQueries = true;
+ settings = {
+ server = {
+ hide-identity = true;
+ hide-version = true;
+ harden-glue = true;
+ harden-dnssec-stripped = true;
+ # 0x20-encoded randomization
+ use-caps-for-id = true;
+
+ # DNSSEC - enabled by default with auto-trust-anchor-file
+ # auto-trust-anchor-file = "/var/lib/unbound/root.key";
+ };
+ };
+ };
+ users = {
+ users = {
+ unbound = {
+ uid = config.vhack.constants.ids.uids.unbound;
+ group = "unbound";
+ };
+ };
+ groups = {
+ unbound = {
+ gid = config.vhack.constants.ids.gids.unbound;
+ };
+ };
+ };
+ };
+}
diff --git a/modules/common/vhack/default.nix b/modules/common/vhack/default.nix
index 4c9e2ae..5821ed9 100644
--- a/modules/common/vhack/default.nix
+++ b/modules/common/vhack/default.nix
@@ -1,4 +1,8 @@
-{...}: {
+{
+ lib,
+ config,
+ ...
+}: {
vhack = {
anubis.enable = true;
@@ -28,6 +32,21 @@
nixconfig.enable = true;
openssh.enable = true;
+ # A local dns server is not _necessary_ but it helps, especially with resolving the
+ # local zones we advertise via nsd.
+ unbound.enable = true;
+
+ # Both servers host the same zones, because why not, it at least improves redundancy
+ nsd = {
+ enable = true;
+ openFirewall = true;
+ interfaces = [
+ (builtins.head config.networking.interfaces.eth0.ipv4.addresses).address
+ (builtins.head config.networking.interfaces.eth0.ipv6.addresses).address
+ ];
+ zones = import ../../../zones {inherit lib;};
+ };
+
persist = {
enable = true;