2020-10-12 00:22:58 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
2021-07-02 22:36:30 +00:00
|
|
|
cfg = config.targets.genericLinux;
|
|
|
|
|
2020-10-12 00:22:58 +00:00
|
|
|
profileDirectory = config.home.profileDirectory;
|
|
|
|
|
2023-01-10 09:35:00 +00:00
|
|
|
nixPkg = if config.nix.package == null then pkgs.nix else config.nix.package;
|
|
|
|
|
2020-10-12 00:22:58 +00:00
|
|
|
in {
|
2021-07-02 22:36:30 +00:00
|
|
|
imports = [
|
|
|
|
(mkRenamedOptionModule [ "targets" "genericLinux" "extraXdgDataDirs" ] [
|
|
|
|
"xdg"
|
|
|
|
"systemDirs"
|
|
|
|
"data"
|
|
|
|
])
|
|
|
|
];
|
|
|
|
|
2020-10-12 00:22:58 +00:00
|
|
|
options.targets.genericLinux = {
|
|
|
|
enable = mkEnableOption "" // {
|
|
|
|
description = ''
|
|
|
|
Whether to enable settings that make Home Manager work better on
|
|
|
|
GNU/Linux distributions other than NixOS.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-07-02 22:36:30 +00:00
|
|
|
config = mkIf cfg.enable {
|
2021-11-04 16:42:44 +00:00
|
|
|
assertions = [
|
|
|
|
(hm.assertions.assertPlatform "targets.genericLinux" pkgs platforms.linux)
|
|
|
|
];
|
|
|
|
|
2021-07-02 22:36:30 +00:00
|
|
|
xdg.systemDirs.data = [
|
|
|
|
# Nix profiles
|
|
|
|
"\${NIX_STATE_DIR:-/nix/var/nix}/profiles/default/share"
|
|
|
|
"${profileDirectory}/share"
|
|
|
|
|
|
|
|
# Distribution-specific
|
|
|
|
"/usr/share/ubuntu"
|
|
|
|
"/usr/local/share"
|
|
|
|
"/usr/share"
|
|
|
|
"/var/lib/snapd/desktop"
|
|
|
|
];
|
2020-10-12 00:22:58 +00:00
|
|
|
|
2023-01-10 09:35:00 +00:00
|
|
|
# We need to append system-wide FHS directories due to the default prefix
|
|
|
|
# resolving to the Nix store.
|
|
|
|
# https://github.com/nix-community/home-manager/pull/2891#issuecomment-1101064521
|
|
|
|
home.sessionVariables = {
|
|
|
|
XCURSOR_PATH = "$XCURSOR_PATH\${XCURSOR_PATH:+:}" + concatStringsSep ":" [
|
|
|
|
"${config.home.profileDirectory}/share/icons"
|
|
|
|
"/usr/share/icons"
|
|
|
|
"/usr/share/pixmaps"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2020-10-12 00:22:58 +00:00
|
|
|
home.sessionVariablesExtra = ''
|
2023-01-10 09:35:00 +00:00
|
|
|
. "${nixPkg}/etc/profile.d/nix.sh"
|
2021-07-02 22:36:30 +00:00
|
|
|
|
|
|
|
# reset TERM with new TERMINFO available (if any)
|
|
|
|
export TERM="$TERM"
|
2020-10-12 00:22:58 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# We need to source both nix.sh and hm-session-vars.sh as noted in
|
|
|
|
# https://github.com/nix-community/home-manager/pull/797#issuecomment-544783247
|
|
|
|
programs.bash.initExtra = ''
|
2023-01-10 09:35:00 +00:00
|
|
|
. "${nixPkg}/etc/profile.d/nix.sh"
|
2020-10-12 00:22:58 +00:00
|
|
|
. "${profileDirectory}/etc/profile.d/hm-session-vars.sh"
|
|
|
|
'';
|
|
|
|
|
2021-11-04 16:42:44 +00:00
|
|
|
programs.zsh.envExtra = ''
|
|
|
|
# Make system functions available to zsh
|
|
|
|
() {
|
|
|
|
setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB
|
|
|
|
|
|
|
|
local system_fpaths=(
|
|
|
|
# Package default
|
|
|
|
/usr/share/zsh/site-functions(/-N)
|
|
|
|
|
|
|
|
# Debian
|
|
|
|
/usr/share/zsh/functions/**/*(/-N)
|
|
|
|
/usr/share/zsh/vendor-completions/(/-N)
|
|
|
|
/usr/share/zsh/vendor-functions/(/-N)
|
|
|
|
)
|
|
|
|
fpath=(''${fpath} ''${system_fpaths})
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
2021-07-02 22:36:30 +00:00
|
|
|
systemd.user.sessionVariables = let
|
|
|
|
# https://github.com/archlinux/svntogit-packages/blob/packages/ncurses/trunk/PKGBUILD
|
|
|
|
# https://salsa.debian.org/debian/ncurses/-/blob/master/debian/rules
|
|
|
|
# https://src.fedoraproject.org/rpms/ncurses/blob/main/f/ncurses.spec
|
|
|
|
# https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-libs/ncurses/ncurses-6.2-r1.ebuild
|
|
|
|
distroTerminfoDirs = concatStringsSep ":" [
|
|
|
|
"/etc/terminfo" # debian, fedora, gentoo
|
|
|
|
"/lib/terminfo" # debian
|
|
|
|
"/usr/share/terminfo" # package default, all distros
|
|
|
|
];
|
|
|
|
in {
|
2024-06-04 18:23:39 +00:00
|
|
|
NIX_PATH = if config.nix.enable
|
|
|
|
&& (config.nix.settings.use-xdg-base-directories or false) then
|
|
|
|
"${config.xdg.stateHome}/nix/defexpr/channels\${NIX_PATH:+:}$NIX_PATH"
|
|
|
|
else
|
|
|
|
"$HOME/.nix-defexpr/channels\${NIX_PATH:+:}$NIX_PATH";
|
2021-07-02 22:36:30 +00:00
|
|
|
TERMINFO_DIRS =
|
|
|
|
"${profileDirectory}/share/terminfo:$TERMINFO_DIRS\${TERMINFO_DIRS:+:}${distroTerminfoDirs}";
|
2020-10-12 00:22:58 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|