summary refs log tree commit diff
path: root/nixos/modules/system/boot/resolved.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/modules/system/boot/resolved.nix')
-rw-r--r--nixos/modules/system/boot/resolved.nix38
1 files changed, 38 insertions, 0 deletions
diff --git a/nixos/modules/system/boot/resolved.nix b/nixos/modules/system/boot/resolved.nix
new file mode 100644
index 00000000000..ecd547322d3
--- /dev/null
+++ b/nixos/modules/system/boot/resolved.nix
@@ -0,0 +1,38 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+{
+
+  options = {
+
+    services.resolved.enable = mkOption {
+      default = false;
+      type = types.bool;
+      description = ''
+        Whether to enable the systemd DNS resolver daemon.
+      '';
+    };
+
+  };
+
+  config = mkIf config.services.resolved.enable {
+
+    systemd.additionalUpstreamSystemUnits = [ "systemd-resolved.service" ];
+
+    systemd.services.systemd-resolved = {
+      wantedBy = [ "multi-user.target" ];
+      restartTriggers = [ config.environment.etc."systemd/resolved.conf".source ];
+    };
+
+    environment.etc."systemd/resolved.conf".text = ''
+      [Resolve]
+      DNS=${concatStringsSep " " config.networking.nameservers}
+    '';
+
+    users.extraUsers.systemd-resolve.uid = config.ids.uids.systemd-resolve;
+    users.extraGroups.systemd-resolve.gid = config.ids.gids.systemd-resolve;
+
+  };
+
+}