mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-28 00:24:18 +00:00
c87977e97d
Otherwise, the enabled -> disabled transition won't be handled correctly (switch-to-configuration currently assumes that if a unit is running and exists, it should be restarted).
39 lines
862 B
Nix
39 lines
862 B
Nix
{ 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;
|
|
|
|
};
|
|
|
|
}
|