/etc/hosts and /etc/nsswitch.conf cleanups

fixes #18183
This commit is contained in:
Peter Hoeg 2016-09-01 17:00:20 +08:00 committed by Jörg Thalheim
parent 8bfe3d7846
commit 987aac7794
No known key found for this signature in database
GPG Key ID: CA4106B8D7CC79FA
1 changed files with 27 additions and 13 deletions

View File

@ -10,9 +10,21 @@ let
inherit (config.services.samba) nsswins; inherit (config.services.samba) nsswins;
ldap = (config.users.ldap.enable && config.users.ldap.nsswitch); ldap = (config.users.ldap.enable && config.users.ldap.nsswitch);
in hostArray = [ "files" "mymachines" ]
++ optionals nssmdns [ "mdns_minimal [!UNAVAIL=return]" ]
++ optionals nsswins [ "wins" ]
++ [ "dns" ]
++ optionals nssmdns [ "mdns" ]
++ ["myhostname" ];
{ passwdArray = [ "files" ]
++ optionals ldap [ "ldap" ]
++ [ "mymachines" ];
shadowArray = [ "files" ]
++ optionals ldap [ "ldap" ];
in {
options = { options = {
# NSS modules. Hacky! # NSS modules. Hacky!
@ -39,17 +51,19 @@ in
# Name Service Switch configuration file. Required by the C # Name Service Switch configuration file. Required by the C
# library. !!! Factor out the mdns stuff. The avahi module # library. !!! Factor out the mdns stuff. The avahi module
# should define an option used by this module. # should define an option used by this module.
environment.etc."nsswitch.conf".text = environment.etc."nsswitch.conf".text = ''
'' passwd: ${concatStringsSep " " passwdArray}
passwd: files ${optionalString ldap "ldap"} group: ${concatStringsSep " " passwdArray}
group: files ${optionalString ldap "ldap"} shadow: ${concatStringsSep " " shadowArray}
shadow: files ${optionalString ldap "ldap"}
hosts: files ${optionalString nssmdns "mdns_minimal [NOTFOUND=return]"} dns ${optionalString nssmdns "mdns"} ${optionalString nsswins "wins"} myhostname mymachines hosts: ${concatStringsSep " " hostArray}
networks: files dns networks: files
ethers: files
services: files ethers: files
protocols: files services: files
''; protocols: files
rpc: files
'';
# Systemd provides nss-myhostname to ensure that our hostname # Systemd provides nss-myhostname to ensure that our hostname
# always resolves to a valid IP address. It returns all locally # always resolves to a valid IP address. It returns all locally