-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
xdg.userDirs: improvements #7937
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
base: master
Are you sure you want to change the base?
Conversation
d2f86e2 to
0342467
Compare
khaneliman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like the changes overall, but would be nice to split up the commits a little to separate thoughts.
- null package support
- darwin support
- setSessionVariables option
- directories/bindings transformation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, we should move away from setting XDG_*_DIR as a shell session variable, and make it so every shell uses xdg-user-dirs instead?
I'm curious, why is xdg-user-dirs preferred anyway, given that home-manager owns the configuration and creates the directories?
No,
You’re right, it won’t make much of a difference under Home Manager, because Another issue that arises with the environment variables is that a user may assume that XDG_DESKTOP_DIR="$HOME/temp-desktop" gnome-mangle-desktopwill protect their Desktop directory from whatever mangling is about to occur, when it’s unlikely to have any effect. Of course, having the vars set in the environment can be convenient. And the idiosyncratic format2 of user-dirs.dirs is intended to make it Footnotes
|
|
Thank you for the thorough answer, you're making some good points! |
Everything here works on Darwin, etc.
It defaults to `true` to maintain the current behavior. This is conditionalized on 25.11, so in future `setSessionVariables` will default to `false`.
E.g., use `MISC` instead of `XDG_MISC_DIR`, the same way `xdg-user-dirs-update` works. This is conditionalized on 25.11, so in future `XDG_MISC_DIR` will be disallowed.
0342467 to
c3f3957
Compare
| // ( | ||
| if lib.versionOlder config.home.stateVersion "25.11" then | ||
| lib.mapAttrs' ( | ||
| k: | ||
| let | ||
| name = lib.match "XDG_(.*)_DIR" k; | ||
| in | ||
| lib.nameValuePair (if name == null then k else lib.elemAt name 0) | ||
| ) cfg.extraConfig | ||
| else | ||
| cfg.extraConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make this a louder transition that gives people a chance to know about the effect through an apply function with a warning? That way, we can detect if the string matches the old format, perform the transform, and then warn about the deprecation.
Just gives us the ability to be a true deprecation and can eventually remove the extra logic / tech debt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for letting this languish …
Does this mean the "25.11" conditionalization should be removed completely in favor of the warning?
And should the true/false conditionalization for setSessionVariables stay the way it is (since it’s more of a trivial switch), or should it also move to the warning/deprecation style?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind the stateVersion stuff as a way to prevent breaking existing configs. But, it would be nice to add a warning inside this function when we are going through the old behavior so people can update to the new behavior and we have the ability to remove this stateVersion logic in the future to keep the module simpler.
Description
packageoption;extraConfig(useMISCinstead ofXDG_MISC_DIR, the same wayxdg-user-dirs-updateworks); andsetSessionVariablesoption, which defaults totrueto maintain the current behavior.The last two changes are conditionalized on 25.11, so in future
XDG_MISC_DIRwill be disallowed andsetSessionVariableswill default tofalse.Checklist
Change is backwards compatible.
Code formatted with
nix fmtornix-shell -p treefmt nixfmt deadnix keep-sorted --run treefmt.Code tested through
nix run .#tests -- test-allornix-shell --pure tests -A run.all.Test cases updated/added. See example.
Commit messages are formatted like
See CONTRIBUTING for more information and recent commit messages for examples.
If this PR adds a new module
If this PR adds an exciting new feature or contains a breaking change.