Skip to content

Commit

Permalink
nixos/nscd: use nsncd by default
Browse files Browse the repository at this point in the history
As announced in the NixOS 22.11 release notes, 23.05 will switch NixOS
to using nsncd (a non-caching reimplementation in Rust) as NSS lookup
dispatcher, instead of the buggy and deprecated glibc-provided nscd.

If you need to switch back, set `services.nscd.enableNsncd = false`, but
please open an issue in nixpkgs so your issue can be fixed.
  • Loading branch information
flokli committed Feb 2, 2023
1 parent 56f5f40 commit fbfe290
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
10 changes: 10 additions & 0 deletions nixos/doc/manual/from_md/release-notes/rl-2305.section.xml
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,16 @@
will no longer render properly or cause errors.
</para>
</listitem>
<listitem>
<para>
NixOS now defaults to using nsncd (a non-caching
reimplementation in Rust) as NSS lookup dispatcher, instead of
the buggy and deprecated glibc-provided nscd. If you need to
switch back, set
<literal>services.nscd.enableNsncd = false</literal>, but
please open an issue in nixpkgs so your issue can be fixed.
</para>
</listitem>
<listitem>
<para>
The <literal>dnsmasq</literal> service now takes configuration
Expand Down
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2305.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ In addition to numerous new and upgraded packages, this release has the followin

DocBook option documentation support will be removed in the next release and CommonMark will become the default. DocBook option documentation that has not been migrated until then will no longer render properly or cause errors.

- NixOS now defaults to using nsncd (a non-caching reimplementation in Rust) as NSS lookup dispatcher, instead of the buggy and deprecated glibc-provided nscd. If you need to switch back, set `services.nscd.enableNsncd = false`, but please open an issue in nixpkgs so your issue can be fixed.

- The `dnsmasq` service now takes configuration via the
`services.dnsmasq.settings` attribute set. The option
`services.dnsmasq.extraConfig` will be deprecated when NixOS 22.11 reaches
Expand Down
10 changes: 7 additions & 3 deletions nixos/modules/services/system/nscd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ in

enableNsncd = mkOption {
type = types.bool;
default = false;
default = true;
description = lib.mdDoc ''
Whether to use nsncd instead of nscd.
Whether to use nsncd instead of nscd from glibc.
This is a nscd-compatible daemon, that proxies lookups, without any caching.
Using nscd from glibc is discouraged.
'';
};

Expand All @@ -55,7 +56,10 @@ in
config = mkOption {
type = types.lines;
default = builtins.readFile ./nscd.conf;
description = lib.mdDoc "Configuration to use for Name Service Cache Daemon.";
description = lib.mdDoc ''
Configuration to use for Name Service Cache Daemon.
Only used in case glibc-nscd is used.
'';
};

package = mkOption {
Expand Down
23 changes: 12 additions & 11 deletions nixos/tests/nscd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ in
};

specialisation = {
withGlibcNscd.configuration = { ... }: {
services.nscd.enableNsncd = false;
};
withUnscd.configuration = { ... }: {
services.nscd.enableNsncd = false;
services.nscd.package = pkgs.unscd;
};
withNsncd.configuration = { ... }: {
services.nscd.enableNsncd = true;
};
};
};

Expand Down Expand Up @@ -118,6 +119,14 @@ in
test_host_lookups()
test_nss_myhostname()
with subtest("glibc-nscd"):
machine.succeed('${specialisations}/withGlibcNscd/bin/switch-to-configuration test')
machine.wait_for_unit("default.target")
test_dynamic_user()
test_host_lookups()
test_nss_myhostname()
with subtest("unscd"):
machine.succeed('${specialisations}/withUnscd/bin/switch-to-configuration test')
machine.wait_for_unit("default.target")
Expand All @@ -129,13 +138,5 @@ in
# known to fail, unscd doesn't load external NSS modules
# test_nss_myhostname()
with subtest("nsncd"):
machine.succeed('${specialisations}/withNsncd/bin/switch-to-configuration test')
machine.wait_for_unit("default.target")
test_dynamic_user()
test_host_lookups()
test_nss_myhostname()
'';
})

0 comments on commit fbfe290

Please sign in to comment.