nixos/resolvconf: add a resolvconf group

This group is useful to allow specific users to run resolvconf and
(and this modify /etc/resolv.conf) without root privileges.
This commit is contained in:
rnhmjoj 2023-12-24 23:40:36 +01:00
parent 9387bb897b
commit 19a494135a
No known key found for this signature in database
GPG Key ID: BFBAF4C975F76450

View File

@ -132,6 +132,8 @@ in
}
(lib.mkIf cfg.enable {
users.groups.resolvconf = {};
networking.resolvconf.package = pkgs.openresolv;
environment.systemPackages = [ cfg.package ];
@ -143,12 +145,13 @@ in
wants = [ "network-pre.target" ];
wantedBy = [ "multi-user.target" ];
restartTriggers = [ config.environment.etc."resolvconf.conf".source ];
serviceConfig.RemainAfterExit = true;
serviceConfig = {
Type = "oneshot";
ExecStart = "${cfg.package}/bin/resolvconf -u";
RemainAfterExit = true;
};
script = ''
${lib.getExe cfg.package} -u
chgrp -R resolvconf /etc/resolv.conf /run/resolvconf
chmod -R g=u /etc/resolv.conf /run/resolvconf
'';
};
})