forked from mirrors/nixpkgs
nixos/systemd: move NSS module logic to systemd module
We keep the conditional on only adding if nscd is enabled for now.
This commit is contained in:
parent
7426bec45e
commit
c0995d22ee
|
@ -8,8 +8,6 @@ let
|
||||||
|
|
||||||
# only with nscd up and running we can load NSS modules that are not integrated in NSS
|
# only with nscd up and running we can load NSS modules that are not integrated in NSS
|
||||||
canLoadExternalModules = config.services.nscd.enable;
|
canLoadExternalModules = config.services.nscd.enable;
|
||||||
myhostname = canLoadExternalModules;
|
|
||||||
mymachines = canLoadExternalModules;
|
|
||||||
# XXX Move these to their respective modules
|
# XXX Move these to their respective modules
|
||||||
nssmdns = canLoadExternalModules && config.services.avahi.nssmdns;
|
nssmdns = canLoadExternalModules && config.services.avahi.nssmdns;
|
||||||
nsswins = canLoadExternalModules && config.services.samba.nsswins;
|
nsswins = canLoadExternalModules && config.services.samba.nsswins;
|
||||||
|
@ -17,19 +15,15 @@ let
|
||||||
|
|
||||||
hostArray = mkMerge [
|
hostArray = mkMerge [
|
||||||
(mkBefore [ "files" ])
|
(mkBefore [ "files" ])
|
||||||
(mkIf mymachines [ "mymachines" ])
|
|
||||||
(mkIf nssmdns [ "mdns_minimal [NOTFOUND=return]" ])
|
(mkIf nssmdns [ "mdns_minimal [NOTFOUND=return]" ])
|
||||||
(mkIf nsswins [ "wins" ])
|
(mkIf nsswins [ "wins" ])
|
||||||
(mkAfter [ "dns" ])
|
(mkAfter [ "dns" ])
|
||||||
(mkIf nssmdns (mkOrder 1501 [ "mdns" ])) # 1501 to ensure it's after dns
|
(mkIf nssmdns (mkOrder 1501 [ "mdns" ])) # 1501 to ensure it's after dns
|
||||||
(mkIf myhostname (mkOrder 1600 [ "myhostname" ])) # 1600 to ensure it's always the last
|
|
||||||
];
|
];
|
||||||
|
|
||||||
passwdArray = mkMerge [
|
passwdArray = mkMerge [
|
||||||
(mkBefore [ "files" ])
|
(mkBefore [ "files" ])
|
||||||
(mkIf ldap [ "ldap" ])
|
(mkIf ldap [ "ldap" ])
|
||||||
(mkIf mymachines [ "mymachines" ])
|
|
||||||
(mkIf canLoadExternalModules (mkAfter [ "systemd" ]))
|
|
||||||
];
|
];
|
||||||
|
|
||||||
shadowArray = mkMerge [
|
shadowArray = mkMerge [
|
||||||
|
@ -157,12 +151,5 @@ in {
|
||||||
hosts = hostArray;
|
hosts = hostArray;
|
||||||
services = mkBefore [ "files" ];
|
services = mkBefore [ "files" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
# Systemd provides nss-myhostname to ensure that our hostname
|
|
||||||
# always resolves to a valid IP address. It returns all locally
|
|
||||||
# configured IP addresses, or ::1 and 127.0.0.2 as
|
|
||||||
# fallbacks. Systemd also provides nss-mymachines to return IP
|
|
||||||
# addresses of local containers.
|
|
||||||
system.nssModules = (optionals canLoadExternalModules [ config.systemd.package.out ]);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -827,6 +827,27 @@ in
|
||||||
|
|
||||||
system.build.units = cfg.units;
|
system.build.units = cfg.units;
|
||||||
|
|
||||||
|
# Systemd provides various NSS modules to look up dynamic users, locally
|
||||||
|
# configured IP adresses and local container hostnames.
|
||||||
|
# On NixOS, these can only be passed to the NSS system via nscd (and its
|
||||||
|
# LD_LIBRARY_PATH), which is why it's usually a very good idea to have nscd
|
||||||
|
# enabled (also see the config.nscd.enable description).
|
||||||
|
# While there is already an assertion in place complaining loudly about
|
||||||
|
# having nssModules configured and nscd disabled, for some reason we still
|
||||||
|
# check for nscd being enabled before adding to nssModules.
|
||||||
|
system.nssModules = optional config.services.nscd.enable systemd.out;
|
||||||
|
system.nssDatabases = mkIf config.services.nscd.enable {
|
||||||
|
hosts = (mkMerge [
|
||||||
|
[ "mymachines" ]
|
||||||
|
(mkOrder 1600 [ "myhostname" ] # 1600 to ensure it's always the last
|
||||||
|
)
|
||||||
|
]);
|
||||||
|
passwd = (mkMerge [
|
||||||
|
[ "mymachines" ]
|
||||||
|
(mkAfter [ "systemd" ])
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
|
||||||
environment.systemPackages = [ systemd ];
|
environment.systemPackages = [ systemd ];
|
||||||
|
|
||||||
environment.etc = let
|
environment.etc = let
|
||||||
|
|
Loading…
Reference in a new issue