fork/home-manager
git clone https://git.julia.blue/fork/home-manager
183a62f3
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . targets . genericLinux ; 8 9profileDirectory = config . home . profileDirectory ; 10 11nixPkg = if config . nix . package == null then pkgs . nix else config . nix . package ; 12 13in { 14imports = [ 15( mkRenamedOptionModule [ "targets" "genericLinux" "extraXdgDataDirs" ] [ 16"xdg" 17"systemDirs" 18"data" 19]) 20]; 21 22options . targets . genericLinux = { 23enable = mkEnableOption "" // { 24description = '' 25Whether to enable settings that make Home Manager work better on 26GNU/Linux distributions other than NixOS. 27'' ; 28}; 29}; 30 31config = mkIf cfg . enable { 32assertions = [ 33( hm . assertions . assertPlatform "targets.genericLinux" pkgs platforms . linux ) 34]; 35 36xdg . systemDirs . data = [ 37# Nix profiles 38"\${NIX_STATE_DIR:-/nix/var/nix}/profiles/default/share" 39" ${ profileDirectory } /share" 40 41# Distribution-specific 42"/usr/share/ubuntu" 43"/usr/local/share" 44"/usr/share" 45"/var/lib/snapd/desktop" 46]; 47 48# We need to append system-wide FHS directories due to the default prefix 49# resolving to the Nix store. 50# https://github.com/nix-community/home-manager/pull/2891#issuecomment-1101064521 51home . sessionVariables = { 52XCURSOR_PATH = "$XCURSOR_PATH\${XCURSOR_PATH:+:}" + concatStringsSep ":" [ 53" ${ config . home . profileDirectory } /share/icons" 54"/usr/share/icons" 55"/usr/share/pixmaps" 56]; 57}; 58 59home . sessionVariablesExtra = '' 60. " ${ nixPkg } /etc/profile.d/nix.sh" 61 62# reset TERM with new TERMINFO available (if any) 63export TERM="$TERM" 64'' ; 65 66# We need to source both nix.sh and hm-session-vars.sh as noted in 67# https://github.com/nix-community/home-manager/pull/797#issuecomment-544783247 68programs . bash . initExtra = '' 69. " ${ nixPkg } /etc/profile.d/nix.sh" 70. " ${ profileDirectory } /etc/profile.d/hm-session-vars.sh" 71'' ; 72 73programs . zsh . envExtra = '' 74# Make system functions available to zsh 75() { 76setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB 77 78local system_fpaths=( 79# Package default 80/usr/share/zsh/site-functions(/-N) 81 82# Debian 83/usr/share/zsh/functions/**/*(/-N) 84/usr/share/zsh/vendor-completions/(/-N) 85/usr/share/zsh/vendor-functions/(/-N) 86) 87fpath=(''${fpath} ''${system_fpaths}) 88} 89'' ; 90 91systemd . user . sessionVariables = let 92# https://github.com/archlinux/svntogit-packages/blob/packages/ncurses/trunk/PKGBUILD 93# https://salsa.debian.org/debian/ncurses/-/blob/master/debian/rules 94# https://src.fedoraproject.org/rpms/ncurses/blob/main/f/ncurses.spec 95# https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-libs/ncurses/ncurses-6.2-r1.ebuild 96distroTerminfoDirs = concatStringsSep ":" [ 97"/etc/terminfo" # debian, fedora, gentoo 98"/lib/terminfo" # debian 99"/usr/share/terminfo" # package default, all distros 100]; 101in { 102NIX_PATH = "$HOME/.nix-defexpr/channels\${NIX_PATH:+:}$NIX_PATH" ; 103TERMINFO_DIRS = 104" ${ profileDirectory } /share/terminfo:$TERMINFO_DIRS\${TERMINFO_DIRS:+:} ${ distroTerminfoDirs } " ; 105}; 106}; 107}