Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos: write our hostname to /etc/hosts #18183

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions nixos/modules/config/nsswitch.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ let
inherit (config.services.samba) nsswins;
ldap = (config.users.ldap.enable && config.users.ldap.nsswitch);

hostArray = with lib; [
Copy link
Member

@Mic92 Mic92 Dec 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with lib; is unnecessary here.

"files"
"mymachines"
] ++ optionals nssmdns [ "mdns_minimal [!UNAVAIL=return] mdns" ]
++ optionals nsswins [ "wins" ]
++ [ "dns" "myhostname" ];

passwdArray = with lib; [
"files"
] ++ optionals ldap [ "ldap" ]
++ [ "mymachines" ];

shadowArray = with lib; [
"files"
] ++ optionals ldap [ "ldap" ];

in

{
Expand Down Expand Up @@ -39,17 +55,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