diff options
author | Kaiden Fey <kookie@spacekookie.de> | 2020-09-21 14:12:32 +0200 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2020-09-21 14:12:32 +0200 |
commit | f80843dd45d7acd563d0a5b014cec3a2ea686fc2 (patch) | |
tree | 87189d873d6f932d85f9c1a480462b37d96cd6a5 /home-manager/modules/targets/generic-linux.nix | |
parent | e0800985dab8f8ebb4cebdfd7e361fd1fafdb2a7 (diff) | |
parent | 9b1b55ba0264a55add4b7b4e022bdc2832b531f6 (diff) |
Merge commit '9b1b55ba0264a55add4b7b4e022bdc2832b531f6'
Diffstat (limited to 'home-manager/modules/targets/generic-linux.nix')
-rw-r--r-- | home-manager/modules/targets/generic-linux.nix | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/home-manager/modules/targets/generic-linux.nix b/home-manager/modules/targets/generic-linux.nix new file mode 100644 index 00000000000..47fcc87b3c0 --- /dev/null +++ b/home-manager/modules/targets/generic-linux.nix @@ -0,0 +1,52 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + profileDirectory = config.home.profileDirectory; + +in { + options.targets.genericLinux = { + enable = mkEnableOption "" // { + description = '' + Whether to enable settings that make Home Manager work better on + GNU/Linux distributions other than NixOS. + ''; + }; + + 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>. + ''; + }; + }; + + config = mkIf config.targets.genericLinux.enable { + home.sessionVariables = let + profiles = + [ "\${NIX_STATE_DIR:-/nix/var/nix}/profiles/default" profileDirectory ]; + dataDirs = concatStringsSep ":" + (map (profile: "${profile}/share") profiles + ++ config.targets.genericLinux.extraXdgDataDirs); + 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"; + }; + }; +} |