Using Win11 WSL-Ubuntu 22.04 inside powershell, I installed home-manager v24.05 using curl and used Nixpkgs v24.05 channel. Then edited ~/.config/home-manager/home.nix and added: xdg.enable = true;
Afterwards, on the command line I run home-manager switch; I get XDG_RUNTIME_DIR and non-standard value of XDG_DATA_DIRS but I don’t get to have other XDG_XXX environment variables created and assigned with proper values.
If, instead, I do
{
home.sessionVariables = {
XDG_CACHE_HOME = “$HOME/.cache”;
XDG_CONFIG_HOME = “$HOME/.config”;
…
};
}
then I get all kinds of conflicts. Any simple fix?
Thanks for the discussion. I rebooted my windows machine and nothing new happened.
After setting xdg env vars thru home.sessionVariables in my home.nix (which defeats the purpose of xdg.enable = true;) I ran the following command: $ home-manager switch
and I got the following error:
error:
… while calling the 'derivationStrict' builtin
at <nix/derivation-internal.nix>:9:12:
8|
9| strict = derivationStrict drvAttrs;
| ^
10|
… while evaluating derivation 'home-manager-generation'
whose name attribute is located at /nix/store/js49clna89jkq2rlz9qfya70hbrxraiq-nixpkgs-24.05/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:333:7
… while evaluating attribute 'buildCommand' of derivation 'home-manager-generation'
at /nix/store/js49clna89jkq2rlz9qfya70hbrxraiq-nixpkgs-24.05/nixpkgs/pkgs/build-support/trivial-builders/default.nix:68:17:
67| enableParallelBuilding = true;
68| inherit buildCommand name;
| ^
69| passAsFile = [ "buildCommand" ]
… while evaluating the option `home.activation.installPackages.data':
… while evaluating definitions from `/home/username/.nix-defexpr/channels/home-manager/modules/home-environment.nix':
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: The option `home.sessionVariables.XDG_CACHE_HOME' has conflicting definition values:
- In `/home/username/.nix-defexpr/channels/home-manager/modules/misc/xdg.nix': "/home/username/.cache"
- In `/home/username/.config/home-manager/home.nix': "$HOME/.cache"
Use `lib.mkForce value` or `lib.mkDefault value` to change the priority on any of these definitions.
Both the definitions are the same. I am happy with the first definition and I don’t want to use home.sessionVariables block. The problem is that the first definition, which is the outcome of xdg.enable = true; is NOT adding any xdg variables in my bash terminal even after reboots. I want to continue with the default xdg definitions but I can’t get it to work.
It works, thanks.
The solution was to write in home.nix:
programs.bash.enable = true;
It wasn’t mentioned anywhere in Home-Manager Manual or Appendix. Perhaps it can be added to this document: Home Manager Manual
and
(Home Manager Manual)
It can easily save precious hours/days of busy developers, whom are making use of Nix home-manager to maintain their work machines.