I’ve been having issues with some services (namely nscd and avahi) since reinstalling NixOS to a new drive. The timing coincided with me switching to btrfs (with a separate subvolume for /nix), but I don’t know if this matters for the issue. I’ve been trying to get help on the Nix Discord, but unfortunately there no one was able to help, so I’m hoping it can get some more exposure here.
When trying to use mDNS services I’ve noticed that the domain name resolving doesn’t work. It turned out that a couple of necessary services were marked as masked and not running (namely avahi-daemon.socket
and nscd.service
). I looked up their configurations and they were empty.
My system is configured using a flake. When using nix-repl to inspect the flake output, the service configuration seems correct (it is enabled, and it has a service file text):
nix-repl> outputs.nixosConfigurations.phalconix.config.systemd.units."nscd.service"
{ aliases = [ ... ]; enable = true; overrideStrategy = "asDropinIfExists"; requiredBy = [ ... ]; text = "[Unit]\n<...>"; unit = «derivation /nix/store/jzfq3bj8f0i6wllpq8ck7ni7b0wc22zh-unit-nscd.service.drv»; wantedBy = [ ... ]; }
The derivation listed above also seems fine:
"buildCommand": "name=nscd.service\nmkdir -p \"$out/$(dirname -- \"$name\")\"\necho -n \"$text\" > \"$out/$name\"\n",
"out": "/nix/store/app76fi5p5dbz488lfjmh10bnn213zsd-unit-nscd.service",
"name": "unit-nscd.service",
"text":"[Unit]\n<...>",
But when building the derivation the output is an empty file:
[nix-shell:~/.dotfiles]$ ls -lah /nix/store/app76fi5p5dbz488lfjmh10bnn213zsd-unit-nscd.service/nscd.service
-r--r--r-- 1 root root 0 Jan 1 1970 /nix/store/app76fi5p5dbz488lfjmh10bnn213zsd-unit-nscd.service/nscd.service
How can it be that the file ends up empty, even though the derivation clearly adds text to it? I tried rerunning nix build --rebuild ...
on the derivation, but that didn’t produce any output and left the file empty.