The use-xdg-base-directories Nix setting can be set globally in /etc/nix/nix.conf, in which case Home Manager doesn't know about it. Users could fix that by also setting it, redundantly, in `nix.settings`, but then Nix issues a lot of spurious warnings about use-xdg-base-directories being a restricted setting that untrusted users can't pass on to the daemon. As an alternative, users can now set `nix.assumeXdg`, which makes Home Manager assume that use-xdg-base-directories is in effect without adding it to the user's nix.conf file.
39 lines
1.2 KiB
Nix
39 lines
1.2 KiB
Nix
{ lib, pkgs, ... }:
|
|
let
|
|
expectedXdgDataDirs = lib.concatStringsSep ":" [
|
|
"\${NIX_STATE_DIR:-/nix/var/nix}/profiles/default/share"
|
|
"/home/hm-user/.local/state/nix/profile/share"
|
|
"/usr/share/ubuntu"
|
|
"/usr/local/share"
|
|
"/usr/share"
|
|
"/var/lib/snapd/desktop"
|
|
"/foo"
|
|
];
|
|
in
|
|
{
|
|
config = {
|
|
targets.genericLinux.enable = true;
|
|
|
|
xdg.systemDirs.data = [ "/foo" ];
|
|
|
|
nix.assumeXdg = true;
|
|
|
|
nmt.script = ''
|
|
envFile=home-files/.config/environment.d/10-home-manager.conf
|
|
assertFileExists $envFile
|
|
assertFileContains $envFile \
|
|
'XDG_DATA_DIRS=${expectedXdgDataDirs}''${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}'
|
|
assertFileContains $envFile \
|
|
'TERMINFO_DIRS=/home/hm-user/.local/state/nix/profile/share/terminfo:$TERMINFO_DIRS''${TERMINFO_DIRS:+:}/etc/terminfo:/lib/terminfo:/usr/share/terminfo'
|
|
|
|
sessionVarsFile=home-path/etc/profile.d/hm-session-vars.sh
|
|
assertFileExists $sessionVarsFile
|
|
assertFileContains $sessionVarsFile \
|
|
'. "${pkgs.nix}/etc/profile.d/nix.sh"'
|
|
|
|
assertFileContains \
|
|
home-path/etc/profile.d/hm-session-vars.sh \
|
|
'export TERM="$TERM"'
|
|
'';
|
|
};
|
|
}
|