Skip to content

Commit

Permalink
/etc/hosts and /etc/nsswitch.conf cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Hoeg authored and bartoldeman committed Apr 12, 2017
1 parent 56d8eca commit 0b7f850
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions nixos/modules/config/nsswitch.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,21 @@ let
inherit (config.services.samba) nsswins;
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 = {

# NSS modules. Hacky!
Expand All @@ -39,17 +51,19 @@ in
# 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 ${optionalString ldap "ldap"}
group: files ${optionalString ldap "ldap"}
shadow: files ${optionalString ldap "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
'';
environment.etc."nsswitch.conf".text = ''
passwd: ${concatStringsSep " " passwdArray}
group: ${concatStringsSep " " passwdArray}
shadow: ${concatStringsSep " " shadowArray}
hosts: ${concatStringsSep " " hostArray}
networks: files
ethers: files
services: files
protocols: files
rpc: files
'';

# Systemd provides nss-myhostname to ensure that our hostname
# always resolves to a valid IP address. It returns all locally
Expand Down

0 comments on commit 0b7f850

Please sign in to comment.