-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests/plotinus, or NixOS environment variables can not be merged #122244
Comments
I've tried changing a definition to a list, but I must have done something wrong and could not make it work. Refs #122042 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/nixos-environment-variables-can-not-be-merged/13477/1 |
The issue is that
so when it gets passed to
(The conflicting value comes from nixpkgs/nixos/modules/services/x11/display-managers/default.nix Lines 486 to 488 in 6d1934a
|
What if we did environment.variables = mapAttrs (_: toList) config.environment.sessionVariables; instead? This seems to work at least for the use case of #126832. |
Yeah, that should work. Ideally, we would remove the |
Or do something like what's done for systemd's nixpkgs/nixos/modules/system/boot/systemd-unit-options.nix Lines 18 to 28 in 99d6ee5
|
That sounds like a good solution. It does not increase the complexity too much and it can keep BC while resolving this issue. |
By the way, I'm not sure what the |
The systemd-like approach requires that all definition sites agree that it's going to be mergeable, by defining a list. This is error prone. Using an RFC42-style submodule we can move this decision to the option declaration where the intent is clear and definitions can not break the merging. |
I was thinking of using EDIT: I was really just using systemd as an example of a custom merge function, not saying we should use the same merging approach. Sorry if that wasn't clear.
Isn't that orthogonal? Assuming we make a distinct e.g. |
Some variables can not be merged and defining them twice should be an error.
This way everything becomes mergeable, so we can't check this anymore.
Considering the loss of checking, it's not.
List of |
OK, thanks for the clarifications. Sounds good to me now. |
Describe the bug
nix-build -A nixosTests.plotinus
environment.variables
can not be merged when multiple definitions of typestr
are defined. It does work when all definitions are list, although merging may not be appropriate.To Reproduce
Steps to reproduce the behavior:
nix-build -A nixosTests.plotinus
Expected behavior
A merge, as is appropriate for
XDG_DATA_DIRS
, using:
Additional context
Environment variables could be modeled RFC42-style. This allows accurate merging of variables where merging makes sense. It would disallow merging where it is not know to make sense. Merging variables that don't join by
:
would be possible.This type could be exposed to all of NixOS (not just
environment.variables
, but environments insystemd
as well, for example). They could even be used outside NixOS; for example inarion
,nix-processmgt
, etc.Notify maintainers
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.Maintainer information:
The text was updated successfully, but these errors were encountered: