From 03d15fa3744849235ea0dba976cd6582afca4499 Mon Sep 17 00:00:00 2001 From: Soispha Peetz Date: Thu, 26 Nov 2026 21:48:07 +0100 Subject: modules/dns: Separate into `nsd` and `unbound` module They are two sides of a coin, but it makes more sense to be able to only enable one but not the other (at least in `unbounds` case). --- modules/by-name/un/unbound/module.nix | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 modules/by-name/un/unbound/module.nix (limited to 'modules/by-name/un/unbound/module.nix') 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 +# 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 . +{ + 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; + }; + }; + }; + }; +} -- cgit v1.3.1