From b0b0c3d94345050a7f86d1ebc6c56eea4389d030 Mon Sep 17 00:00:00 2001 From: Igor Date: Tue, 27 Feb 2024 21:48:27 +0000 Subject: [PATCH] targets/generic-linux: use xdg path for defexpr Fixes warnings about the non-existent `~/.nix-defexpr` folder when using `use-xdg-base-directories = true`. Example: warning: Nix search path entry '/home/user/.nix-defexpr/channels' does not exist, ignoring Starting Home Manager activation Activating checkFilesChanged Activating checkLinkTargets Activating writeBoundary Activating installPackages replacing old 'home-manager-path' installing 'home-manager-path' Activating dconfSettings Activating linkDesktopApplications Activating linkGeneration Cleaning up orphan links from /home/user No change so reusing latest profile generation 13 Creating home file links in /home/user Activating onFilesChange Activating reloadSystemd warning: Nix search path entry '/home/user/.nix-defexpr/channels' does not exist, ignoring --- modules/targets/generic-linux.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/targets/generic-linux.nix b/modules/targets/generic-linux.nix index b5a07d5fa..9dce9f5c8 100644 --- a/modules/targets/generic-linux.nix +++ b/modules/targets/generic-linux.nix @@ -99,7 +99,11 @@ in { "/usr/share/terminfo" # package default, all distros ]; in { - NIX_PATH = "$HOME/.nix-defexpr/channels\${NIX_PATH:+:}$NIX_PATH"; + NIX_PATH = if config.nix.enable + && (config.nix.settings.use-xdg-base-directories or false) then + "${config.xdg.stateHome}/nix/defexpr/channels\${NIX_PATH:+:}$NIX_PATH" + else + "$HOME/.nix-defexpr/channels\${NIX_PATH:+:}$NIX_PATH"; TERMINFO_DIRS = "${profileDirectory}/share/terminfo:$TERMINFO_DIRS\${TERMINFO_DIRS:+:}${distroTerminfoDirs}"; };