diff --git a/modules/targets/generic-linux.nix b/modules/targets/generic-linux.nix index cf63f621..bdb27926 100644 --- a/modules/targets/generic-linux.nix +++ b/modules/targets/generic-linux.nix @@ -16,7 +16,8 @@ in { config = mkIf config.targets.genericLinux.enable { home.sessionVariables = let - profiles = [ "/nix/var/nix/profiles/default" profileDirectory ]; + profiles = + [ "\${NIX_STATE_DIR:-/nix/var/nix}/profiles/default" profileDirectory ]; dataDirs = concatStringsSep ":" (map (profile: "${profile}/share") profiles); in { XDG_DATA_DIRS = "${dataDirs}\${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS"; }; diff --git a/tests/modules/targets/generic-linux.nix b/tests/modules/targets/generic-linux.nix index 8596ac3d..d9bb85b6 100644 --- a/tests/modules/targets/generic-linux.nix +++ b/tests/modules/targets/generic-linux.nix @@ -10,7 +10,7 @@ with lib; assertFileExists home-path/etc/profile.d/hm-session-vars.sh assertFileContains \ home-path/etc/profile.d/hm-session-vars.sh \ - 'export XDG_DATA_DIRS="/nix/var/nix/profiles/default/share:/home/hm-user/.nix-profile/share''${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS"' + 'export XDG_DATA_DIRS="''${NIX_STATE_DIR:-/nix/var/nix}/profiles/default/share:/home/hm-user/.nix-profile/share''${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS"' assertFileContains \ home-path/etc/profile.d/hm-session-vars.sh \ '. "${pkgs.nix}/etc/profile.d/nix.sh"'