diff options
author | Florian Jacob <projects+git@florianjacob.de> | 2017-06-30 02:20:50 +0200 |
---|---|---|
committer | Florian Jacob <projects+git@florianjacob.de> | 2017-06-30 02:44:23 +0200 |
commit | e370e97f3dab410ac460af3cb9974b8df7b3214d (patch) | |
tree | 1239567be79fd6962441040298c8336f1b248a2c /nixos/modules/config/nsswitch.nix | |
parent | 7410b0c82c2fe57460d5ad3f1b2e1476d7b39c43 (diff) |
nsswitch: only add modules to nsswitch.conf if they can be loaded
Diffstat (limited to 'nixos/modules/config/nsswitch.nix')
-rw-r--r-- | nixos/modules/config/nsswitch.nix | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/nixos/modules/config/nsswitch.nix b/nixos/modules/config/nsswitch.nix index 52d9944a3f2e..16c43a99ad56 100644 --- a/nixos/modules/config/nsswitch.nix +++ b/nixos/modules/config/nsswitch.nix @@ -6,26 +6,29 @@ with lib; let - inherit (config.services.avahi) nssmdns; - inherit (config.services.samba) nsswins; - ldap = (config.users.ldap.enable && config.users.ldap.nsswitch); - sssd = config.services.sssd.enable; - resolved = config.services.resolved.enable; # only with nscd up and running we can load NSS modules that are not integrated in NSS canLoadExternalModules = config.services.nscd.enable; - - hostArray = [ "files" "mymachines" ] + myhostname = canLoadExternalModules; + mymachines = canLoadExternalModules; + nssmdns = canLoadExternalModules && config.services.avahi.nssmdns; + nsswins = canLoadExternalModules && config.services.samba.nsswins; + ldap = canLoadExternalModules && (config.users.ldap.enable && config.users.ldap.nsswitch); + sssd = canLoadExternalModules && config.services.sssd.enable; + resolved = canLoadExternalModules && config.services.resolved.enable; + + hostArray = [ "files" ] + ++ optionals mymachines [ "mymachines" ] ++ optionals nssmdns [ "mdns_minimal [!UNAVAIL=return]" ] ++ optionals nsswins [ "wins" ] ++ optionals resolved ["resolve [!UNAVAIL=return]"] ++ [ "dns" ] ++ optionals nssmdns [ "mdns" ] - ++ ["myhostname" ]; + ++ optionals myhostname ["myhostname" ]; passwdArray = [ "files" ] ++ optional sssd "sss" ++ optionals ldap [ "ldap" ] - ++ [ "mymachines" ]; + ++ optionals mymachines [ "mymachines" ]; shadowArray = [ "files" ] ++ optional sssd "sss" |