Enable systemd's mymachines NSS module

It makes every local container registered with machined resolvable.
This commit is contained in:
Eelco Dolstra 2014-08-24 17:08:55 +02:00
parent 9237e86d99
commit d73025a5fe
2 changed files with 21 additions and 23 deletions

View File

@ -35,29 +35,27 @@ in
config = { config = {
environment.etc = # Name Service Switch configuration file. Required by the C
[ # Name Service Switch configuration file. Required by the C library. # library. !!! Factor out the mdns stuff. The avahi module
# !!! Factor out the mdns stuff. The avahi module should define # should define an option used by this module.
# an option used by this module. environment.etc."nsswitch.conf".text =
{ source = pkgs.writeText "nsswitch.conf" ''
'' passwd: files ldap
passwd: files ldap group: files ldap
group: files ldap shadow: files ldap
shadow: files ldap hosts: files ${optionalString nssmdns "mdns_minimal [NOTFOUND=return]"} dns ${optionalString nssmdns "mdns"} ${optionalString nsswins "wins"} myhostname mymachines
hosts: files ${optionalString nssmdns "mdns_minimal [NOTFOUND=return]"} dns ${optionalString nssmdns "mdns"} ${optionalString nsswins "wins"} myhostname networks: files dns
networks: files dns ethers: files
ethers: files services: files
services: files protocols: files
protocols: files '';
'';
target = "nsswitch.conf";
}
];
# Use nss-myhostname to ensure that our hostname always resolves to # Systemd provides nss-myhostname to ensure that our hostname
# a valid IP address. It returns all locally configured IP # always resolves to a valid IP address. It returns all locally
# addresses, or ::1 and 127.0.0.2 as fallbacks. # configured IP addresses, or ::1 and 127.0.0.2 as
system.nssModules = [ pkgs.systemd ]; # fallbacks. Systemd also provides nss-mymachines to return IP
# addresses of local containers.
system.nssModules = [ config.systemd.package ];
}; };
} }

View File

@ -62,7 +62,7 @@ in
mkdir -m 0755 -p /var/db/nscd 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 = serviceConfig =
{ ExecStart = "@${pkgs.glibc}/sbin/nscd nscd -f ${cfgFile}"; { ExecStart = "@${pkgs.glibc}/sbin/nscd nscd -f ${cfgFile}";