1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 11:36:05 +01:00

targets.genericLinux: add module

PR #797
This commit is contained in:
Tobias Happ 2020-04-05 16:46:55 +02:00 committed by Robert Helgesson
parent dd538c2969
commit d06bcf4c97
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
7 changed files with 87 additions and 0 deletions

View file

@ -0,0 +1,39 @@
{ 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.
'';
};
config = mkIf config.targets.genericLinux.enable {
home.sessionVariables = let
profiles = [ "/nix/var/nix/profiles/default" profileDirectory ];
dataDirs =
concatStringsSep ":" (map (profile: "${profile}/share") profiles);
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";
};
};
}