Running nix eval for systemd service errors, but not for specific fields

I was trying to debug whether a helper I wrote for systemd services was correctly placing environment into the systemd.services.<the-thing>.environment.

Naively I thought I could simply do nix eval --json .#nixosConfigurations.the-system.config.systemd.services.the-thing, however, this errors with error: The option systemd.services.the-thing.startLimitBurst'was accessed but has no value defined. Try setting the option..

Adding .environment explicitly works, however, I was wondering whether:

  1. Is this the correct way to inspect the correctness of a configuration, w.r.t., is that what is really going to be applied
  2. Is this the “right”/canonical way of doing this?
  3. Why do I get this startLimitBurst issue? This gave me the feeling of I am maybe doing something wrong.
  4. Probably very much unrelated but I was wondering how modular services will play into this in the future.

I get the same behaviour when I am not using my helper therefore I did not include it here, because it did not make any difference.

kind regards in advance.

nixos-rebuild repl --flake .#the-system should work. It still gets «error: The option systemd.services.pipewire.startLimitBurst was accessed but has no value defined. Try setting the option.»; errors but they don’t fail the whole thing. Also you can do nix eval '.#nixosConfigurations.the-system.config.systemd.units."the-thing.service".text' to get the final systemd text. Finally, you can run nixos-rebuild build --flake .#the-system to build the system without activating at all, and then you can inspect the /etc of the build configuration.

You may also be interested in Diffing NixOS configurations at the config-level although it does require patched Nix and Nixpkgs.

1 Like