diff --git a/nixos/modules/config/nsswitch.nix b/nixos/modules/config/nsswitch.nix index b601e908e49f..13277fe56e42 100644 --- a/nixos/modules/config/nsswitch.nix +++ b/nixos/modules/config/nsswitch.nix @@ -61,6 +61,15 @@ in { }; }; + system.nssHosts = mkOption { + type = types.listOf types.str; + default = []; + example = [ "mdns" ]; + description = '' + List of host entries to configure in /etc/nsswitch.conf. + ''; + }; + }; config = { @@ -85,7 +94,7 @@ in { group: ${concatStringsSep " " passwdArray} shadow: ${concatStringsSep " " shadowArray} - hosts: ${concatStringsSep " " hostArray} + hosts: ${concatStringsSep " " config.system.nssHosts} networks: files ethers: files @@ -94,6 +103,8 @@ in { rpc: files ''; + system.nssHosts = hostArray; + # 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