Say I have services.foo.enable = true; and environment.systemPackages contains "foo". The latter is often redundant, because the foo service requires the "foo" package. How do I detect such duplicates, where enabling a program or service makes a package entry unnecessary?

In trivial cases a text match would give a pretty good indication of a duplicate, but enabling for example service.xserver.desktopManager.xfce installs a bunch of packages, any one of which I might have listed in environment.systemPackages. Is it possible to detect such duplicates as well?

The main goal is simplifying the configuration. The extreme case would be where I add every single package I need to the package list before enabling them, making for a much bigger configuration than necessary.

A secondary goal is simplifying debugging. I've enabled a program or service, but the system does not do what I expect (for example, a tool related to the program or service is not available on the $PATH). Now, if I had some way of telling that enabling X resulted in package Y being installed, that's one debugging avenue I can exclude immediately.

  • 1
    Why do you want to do this? In regards to your openssh example, those two options mean different things, thus are not redundant. The former sets up sshd to run, and the latter adds the ssh client utilities to your environment (your $PATH). While they may use the same openssh package, those two config options have different purposes, thus one cannot substitute the other. – Emmanuel Rosa Aug 10 '19 at 7:13
  • @EmmanuelRosa Generalized to make the question clearer. – l0b0 Aug 10 '19 at 7:33
  • 1
    Perhaps it would be nice to add some possible motivation? Removing those "duplicates" won't save any space (by definition), and e.g. the fact that Xfce puts some particular package on $PATH doesn't mean it will always do so (though usually that will hold), therefore you might want to specify the package explicitly anyway, assuming you do want it. – Vladimír Čunát Aug 10 '19 at 7:53
  • 1
    I think you're still making the assumption that enabling a service and adding a package to systemPackages are equivalent. These two options overlap when a NixOS module happens to add packages via systemPackages, which is probably what's happening with xfce. Ignoring NixOS modules for a moment, assume I want to install a program which uses ffmpeg. If I add said program to systemPackages it will appear in $PATH, so I can run it. However, ffmpeg will not be in $PATH, so I'd have to find it in the Nix store to run it dirrectly. Note: Vladimir made a good point! – Emmanuel Rosa Aug 10 '19 at 7:56
  • @EmmanuelRosa No, I did say "often redundant", not "always". – l0b0 Aug 10 '19 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.