2020-04-05 16:46:55 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
profileDirectory = config.home.profileDirectory;
|
|
|
|
|
|
|
|
in {
|
2020-09-09 21:52:57 +02:00
|
|
|
options.targets.genericLinux = {
|
|
|
|
enable = mkEnableOption "" // {
|
|
|
|
description = ''
|
|
|
|
Whether to enable settings that make Home Manager work better on
|
|
|
|
GNU/Linux distributions other than NixOS.
|
|
|
|
'';
|
|
|
|
};
|
2020-09-09 21:53:21 +02:00
|
|
|
|
|
|
|
extraXdgDataDirs = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
|
|
|
example = [ "/usr/share" "/usr/local/share" ];
|
|
|
|
description = ''
|
|
|
|
List of directory names to add to <envar>XDG_DATA_DIRS</envar>.
|
|
|
|
'';
|
|
|
|
};
|
2020-04-05 16:46:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf config.targets.genericLinux.enable {
|
|
|
|
home.sessionVariables = let
|
2020-06-14 23:34:53 +02:00
|
|
|
profiles =
|
|
|
|
[ "\${NIX_STATE_DIR:-/nix/var/nix}/profiles/default" profileDirectory ];
|
2020-09-09 21:53:21 +02:00
|
|
|
dataDirs = concatStringsSep ":"
|
|
|
|
(map (profile: "${profile}/share") profiles
|
|
|
|
++ config.targets.genericLinux.extraXdgDataDirs);
|
2020-04-05 16:46:55 +02:00
|
|
|
in { XDG_DATA_DIRS = "${dataDirs}\${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS"; };
|
|
|
|
|
|
|
|
home.sessionVariablesExtra = ''
|
|
|
|
. "${pkgs.nix}/etc/profile.d/nix.sh"
|
|
|
|
'';
|
|
|
|
|
|
|
|
# We need to source both nix.sh and hm-session-vars.sh as noted in
|
|
|
|
# https://github.com/rycee/home-manager/pull/797#issuecomment-544783247
|
|
|
|
programs.bash.initExtra = ''
|
|
|
|
. "${pkgs.nix}/etc/profile.d/nix.sh"
|
|
|
|
. "${profileDirectory}/etc/profile.d/hm-session-vars.sh"
|
|
|
|
'';
|
|
|
|
|
|
|
|
systemd.user.sessionVariables = {
|
|
|
|
NIX_PATH = "$HOME/.nix-defexpr/channels\${NIX_PATH:+:}$NIX_PATH";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|