summary refs log tree commit diff
diff options
context:
space:
mode:
authorNaïm Favier <n@monade.li>2022-03-29 21:14:13 +0200
committerNaïm Favier <n@monade.li>2022-06-21 22:58:43 +0200
commit203696f098d3041b0fc97a0b8358a703de6f0672 (patch)
tree149c12b6524be7cba3958a87ae30f4a5045de6f6
parent0d68d7c857fe301d49cdcd56130e0beea4ecd5aa (diff)
downloadnixpkgs-203696f098d3041b0fc97a0b8358a703de6f0672.tar
nixpkgs-203696f098d3041b0fc97a0b8358a703de6f0672.tar.gz
nixpkgs-203696f098d3041b0fc97a0b8358a703de6f0672.tar.bz2
nixpkgs-203696f098d3041b0fc97a0b8358a703de6f0672.tar.lz
nixpkgs-203696f098d3041b0fc97a0b8358a703de6f0672.tar.xz
nixpkgs-203696f098d3041b0fc97a0b8358a703de6f0672.tar.zst
nixpkgs-203696f098d3041b0fc97a0b8358a703de6f0672.zip
nixos/resolvconf: add `package`
Expose the package that provides the system-wide `resolvconf` command
(either openresolv or systemd) to allow implementation-agnostic modules.
-rw-r--r--nixos/modules/config/resolvconf.nix21
-rw-r--r--nixos/modules/system/boot/resolved.nix4
2 files changed, 21 insertions, 4 deletions
diff --git a/nixos/modules/config/resolvconf.nix b/nixos/modules/config/resolvconf.nix
index 4499481811f..3e14884bb2b 100644
--- a/nixos/modules/config/resolvconf.nix
+++ b/nixos/modules/config/resolvconf.nix
@@ -50,7 +50,20 @@ in
         default = !(config.environment.etc ? "resolv.conf");
         defaultText = literalExpression ''!(config.environment.etc ? "resolv.conf")'';
         description = ''
-          DNS configuration is managed by resolvconf.
+          Whether DNS configuration is managed by resolvconf.
+        '';
+      };
+
+      package = mkOption {
+        type = types.package;
+        default = pkgs.openresolv;
+        defaultText = literalExpression "pkgs.openresolv";
+        description = ''
+          The package that provides the system-wide resolvconf command. Defaults to <literal>openresolv</literal>
+          if this module is enabled. Otherwise, can be used by other modules (for example <option>services.resolved</option>) to
+          provide a compatibility layer.
+
+          This option generally shouldn't be set by the user.
         '';
       };
 
@@ -119,10 +132,12 @@ in
             exit 1
           ''
         else configText;
+
+      environment.systemPackages = [ cfg.package ];
     }
 
     (mkIf cfg.enable {
-      environment.systemPackages = [ pkgs.openresolv ];
+      networking.resolvconf.package = pkgs.openresolv;
 
       systemd.services.resolvconf = {
         description = "resolvconf update";
@@ -134,7 +149,7 @@ in
 
         serviceConfig = {
           Type = "oneshot";
-          ExecStart = "${pkgs.openresolv}/bin/resolvconf -u";
+          ExecStart = "${cfg.package}/bin/resolvconf -u";
           RemainAfterExit = true;
         };
       };
diff --git a/nixos/modules/system/boot/resolved.nix b/nixos/modules/system/boot/resolved.nix
index 21d3fab2f35..3a38201ff60 100644
--- a/nixos/modules/system/boot/resolved.nix
+++ b/nixos/modules/system/boot/resolved.nix
@@ -1,4 +1,4 @@
-{ config, lib, ... }:
+{ config, lib, pkgs, ... }:
 
 with lib;
 let
@@ -178,6 +178,8 @@ in
     # If networkmanager is enabled, ask it to interface with resolved.
     networking.networkmanager.dns = "systemd-resolved";
 
+    networking.resolvconf.package = pkgs.systemd;
+
   };
 
 }