mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
Merge pull request #26967 from florianjacob/fix-systemd-resolved-nsswitch-loading
Fix systemd resolved nsswitch loading and clearly state NSS module's dependency on nscd
This commit is contained in:
commit
1266c8f935
1 changed files with 28 additions and 10 deletions
|
@ -6,24 +6,29 @@ with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
inherit (config.services.avahi) nssmdns;
|
# only with nscd up and running we can load NSS modules that are not integrated in NSS
|
||||||
inherit (config.services.samba) nsswins;
|
canLoadExternalModules = config.services.nscd.enable;
|
||||||
ldap = (config.users.ldap.enable && config.users.ldap.nsswitch);
|
myhostname = canLoadExternalModules;
|
||||||
sssd = config.services.sssd.enable;
|
mymachines = canLoadExternalModules;
|
||||||
resolved = config.services.resolved.enable;
|
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" "mymachines" ]
|
hostArray = [ "files" ]
|
||||||
|
++ optionals mymachines [ "mymachines" ]
|
||||||
++ optionals nssmdns [ "mdns_minimal [!UNAVAIL=return]" ]
|
++ optionals nssmdns [ "mdns_minimal [!UNAVAIL=return]" ]
|
||||||
++ optionals nsswins [ "wins" ]
|
++ optionals nsswins [ "wins" ]
|
||||||
++ optionals resolved ["resolv [!UNAVAIL=return]"]
|
++ optionals resolved ["resolve [!UNAVAIL=return]"]
|
||||||
++ [ "dns" ]
|
++ [ "dns" ]
|
||||||
++ optionals nssmdns [ "mdns" ]
|
++ optionals nssmdns [ "mdns" ]
|
||||||
++ ["myhostname" ];
|
++ optionals myhostname ["myhostname" ];
|
||||||
|
|
||||||
passwdArray = [ "files" ]
|
passwdArray = [ "files" ]
|
||||||
++ optional sssd "sss"
|
++ optional sssd "sss"
|
||||||
++ optionals ldap [ "ldap" ]
|
++ optionals ldap [ "ldap" ]
|
||||||
++ [ "mymachines" ];
|
++ optionals mymachines [ "mymachines" ];
|
||||||
|
|
||||||
shadowArray = [ "files" ]
|
shadowArray = [ "files" ]
|
||||||
++ optional sssd "sss"
|
++ optional sssd "sss"
|
||||||
|
@ -36,6 +41,7 @@ in {
|
||||||
options = {
|
options = {
|
||||||
|
|
||||||
# NSS modules. Hacky!
|
# NSS modules. Hacky!
|
||||||
|
# Only works with nscd!
|
||||||
system.nssModules = mkOption {
|
system.nssModules = mkOption {
|
||||||
type = types.listOf types.path;
|
type = types.listOf types.path;
|
||||||
internal = true;
|
internal = true;
|
||||||
|
@ -55,6 +61,18 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
assertions = [
|
||||||
|
{
|
||||||
|
# generic catch if the NixOS module adding to nssModules does not prevent it with specific message.
|
||||||
|
assertion = config.system.nssModules.path != "" -> canLoadExternalModules;
|
||||||
|
message = "Loading NSS modules from path ${config.system.nssModules.path} requires nscd being enabled.";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
# resolved does not need to add to nssModules, therefore needs an extra assertion
|
||||||
|
assertion = resolved -> canLoadExternalModules;
|
||||||
|
message = "Loading systemd-resolved's nss-resolve NSS module requires nscd being enabled.";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
# Name Service Switch configuration file. Required by the C
|
# Name Service Switch configuration file. Required by the C
|
||||||
# library. !!! Factor out the mdns stuff. The avahi module
|
# library. !!! Factor out the mdns stuff. The avahi module
|
||||||
|
@ -78,7 +96,7 @@ in {
|
||||||
# configured IP addresses, or ::1 and 127.0.0.2 as
|
# configured IP addresses, or ::1 and 127.0.0.2 as
|
||||||
# fallbacks. Systemd also provides nss-mymachines to return IP
|
# fallbacks. Systemd also provides nss-mymachines to return IP
|
||||||
# addresses of local containers.
|
# addresses of local containers.
|
||||||
system.nssModules = [ config.systemd.package.out ];
|
system.nssModules = optionals canLoadExternalModules [ config.systemd.package.out ];
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue