aboutsummaryrefslogtreecommitdiffstats
path: root/modules/by-name/un/unbound/module.nix
diff options
context:
space:
mode:
authorSoispha Peetz <soispha@b-peetz.de>2026-11-26 21:48:07 +0100
committerSoispha Peetz <soispha@b-peetz.de>2026-11-27 00:55:53 +0100
commit03d15fa3744849235ea0dba976cd6582afca4499 (patch)
treeb5edd1a99dc820e1b91ae23154e2f4848a5a453a /modules/by-name/un/unbound/module.nix
parenthosts/*: Include their deployment method in their definition (diff)
downloadnixos-server-03d15fa3744849235ea0dba976cd6582afca4499.zip
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).
Diffstat (limited to '')
-rw-r--r--modules/by-name/un/unbound/module.nix64
1 files changed, 64 insertions, 0 deletions
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;
+ };
+ };
+ };
+ };
+}