From 203696f098d3041b0fc97a0b8358a703de6f0672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Na=C3=AFm=20Favier?= Date: Tue, 29 Mar 2022 21:14:13 +0200 Subject: [PATCH] nixos/resolvconf: add `package` Expose the package that provides the system-wide `resolvconf` command (either openresolv or systemd) to allow implementation-agnostic modules. --- nixos/modules/config/resolvconf.nix | 21 ++++++++++++++++++--- nixos/modules/system/boot/resolved.nix | 4 +++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/nixos/modules/config/resolvconf.nix b/nixos/modules/config/resolvconf.nix index 4499481811fd..3e14884bb2bf 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 openresolv + if this module is enabled. Otherwise, can be used by other modules (for example ) 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 21d3fab2f35d..3a38201ff60d 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; + }; }