diff --git a/nixos/modules/config/nsswitch.nix b/nixos/modules/config/nsswitch.nix index 45695d9cb89f..549e731f3b08 100644 --- a/nixos/modules/config/nsswitch.nix +++ b/nixos/modules/config/nsswitch.nix @@ -35,29 +35,27 @@ in config = { - environment.etc = - [ # Name Service Switch configuration file. Required by the C library. - # !!! Factor out the mdns stuff. The avahi module should define - # an option used by this module. - { source = pkgs.writeText "nsswitch.conf" - '' - passwd: files ldap - group: files ldap - shadow: files ldap - hosts: files ${optionalString nssmdns "mdns_minimal [NOTFOUND=return]"} dns ${optionalString nssmdns "mdns"} ${optionalString nsswins "wins"} myhostname - networks: files dns - ethers: files - services: files - protocols: files - ''; - target = "nsswitch.conf"; - } - ]; + # Name Service Switch configuration file. Required by the C + # library. !!! Factor out the mdns stuff. The avahi module + # should define an option used by this module. + environment.etc."nsswitch.conf".text = + '' + passwd: files ldap + group: files ldap + shadow: files ldap + hosts: files ${optionalString nssmdns "mdns_minimal [NOTFOUND=return]"} dns ${optionalString nssmdns "mdns"} ${optionalString nsswins "wins"} myhostname mymachines + networks: files dns + ethers: files + services: files + protocols: files + ''; - # Use nss-myhostname to ensure that our hostname always resolves to - # a valid IP address. It returns all locally configured IP - # addresses, or ::1 and 127.0.0.2 as fallbacks. - system.nssModules = [ pkgs.systemd ]; + # Systemd provides nss-myhostname to ensure that our hostname + # always resolves to a valid IP address. It returns all locally + # configured IP addresses, or ::1 and 127.0.0.2 as + # fallbacks. Systemd also provides nss-mymachines to return IP + # addresses of local containers. + system.nssModules = [ config.systemd.package ]; }; } diff --git a/nixos/modules/services/system/nscd.nix b/nixos/modules/services/system/nscd.nix index 5460e962ea2c..0879d9b85bd8 100644 --- a/nixos/modules/services/system/nscd.nix +++ b/nixos/modules/services/system/nscd.nix @@ -62,7 +62,7 @@ in mkdir -m 0755 -p /var/db/nscd ''; - restartTriggers = [ config.environment.etc.hosts.source ]; + restartTriggers = [ config.environment.etc.hosts.source config.environment.etc."nsswitch.conf".source ]; serviceConfig = { ExecStart = "@${pkgs.glibc}/sbin/nscd nscd -f ${cfgFile}";