Nix Cookbook: Difference between revisions

imported>Timotheosh
No edit summary
imported>Zie
add error The option has conflicting definitions
Line 138: Line 138:


NOTE: The above fix will make your programs installed by nix visible in your application menu, but you still will not be able to run them, because they are symlinked outside your XDG_DATA_DIRS paths, and are not executable (one or the other criteria must be met to run the program from a menu). This impacts KDE users, and potentially others. I noticed that on native NixOS with KDE, NixOS adds all these paths for each application to one's XDG_DATA_DIRS variable.
NOTE: The above fix will make your programs installed by nix visible in your application menu, but you still will not be able to run them, because they are symlinked outside your XDG_DATA_DIRS paths, and are not executable (one or the other criteria must be met to run the program from a menu). This impacts KDE users, and potentially others. I noticed that on native NixOS with KDE, NixOS adds all these paths for each application to one's XDG_DATA_DIRS variable.
==== error: The option has conflicting definitions ====
If while doing a <syntaxHighlight lang="console">nixos-rebuild switch</syntaxHighlight> you see an error like:
<syntaxHighlight lang="console">
building Nix...
building the system configuration...
error: The option `systemd.services.postfix.serviceConfig.PIDFile' has conflicting definitions, in `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/
services/mail/postfix.nix' and `/etc/nixos/configuration.nix'.
(use '--show-trace' to show detailed location information)
</syntaxHighlight>
This means exactly what it says, but how to fix it?  Assuming one of the nix files is your configuration file, then you want your version to stick, and not the version from some maintainer somewhere, you can use <syntaxHighlight lang="nix">mkOverride </syntaxHighlight>, which is a nix property defined in lib.  so in the example above, the option in conflict is 'systemd.services.postfix.serviceConfig.PIDFile', so to override it you would do something like:
<syntaxHighlight lang="nix">
systemd.services.postfix.serviceConfig.PIDFile = lib.mkOverride 0 "mynewvalue";
</syntaxHighlight>
which will override the other value, and force yours to have priority.