2020-04-05 16:46:55 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
2021-05-11 02:14:42 +02:00
|
|
|
cfg = config.targets.genericLinux;
|
|
|
|
|
2020-04-05 16:46:55 +02:00
|
|
|
profileDirectory = config.home.profileDirectory;
|
|
|
|
|
|
|
|
in {
|
2021-05-11 02:14:42 +02:00
|
|
|
imports = [
|
|
|
|
(mkRenamedOptionModule [ "targets" "genericLinux" "extraXdgDataDirs" ] [
|
|
|
|
"xdg"
|
|
|
|
"systemDirs"
|
|
|
|
"data"
|
|
|
|
])
|
|
|
|
];
|
|
|
|
|
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-04-05 16:46:55 +02:00
|
|
|
};
|
|
|
|
|
2021-05-11 02:14:42 +02:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
xdg.systemDirs.data = [
|
|
|
|
# Nix profiles
|
|
|
|
"\${NIX_STATE_DIR:-/nix/var/nix}/profiles/default/share"
|
|
|
|
"${profileDirectory}/share"
|
2021-03-08 21:41:23 +01:00
|
|
|
|
2021-05-11 02:14:42 +02:00
|
|
|
# Distribution-specific
|
|
|
|
"/usr/share/ubuntu"
|
|
|
|
"/usr/local/share"
|
|
|
|
"/usr/share"
|
|
|
|
"/var/lib/snapd/desktop"
|
|
|
|
];
|
2020-04-05 16:46:55 +02:00
|
|
|
|
|
|
|
home.sessionVariablesExtra = ''
|
|
|
|
. "${pkgs.nix}/etc/profile.d/nix.sh"
|
2021-03-08 21:41:23 +01:00
|
|
|
|
|
|
|
# reset TERM with new TERMINFO available (if any)
|
|
|
|
export TERM="$TERM"
|
2020-04-05 16:46:55 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
# We need to source both nix.sh and hm-session-vars.sh as noted in
|
2020-10-19 21:20:37 +02:00
|
|
|
# https://github.com/nix-community/home-manager/pull/797#issuecomment-544783247
|
2020-04-05 16:46:55 +02:00
|
|
|
programs.bash.initExtra = ''
|
|
|
|
. "${pkgs.nix}/etc/profile.d/nix.sh"
|
|
|
|
. "${profileDirectory}/etc/profile.d/hm-session-vars.sh"
|
|
|
|
'';
|
|
|
|
|
2021-05-11 02:14:42 +02: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 {
|
2020-04-05 16:46:55 +02:00
|
|
|
NIX_PATH = "$HOME/.nix-defexpr/channels\${NIX_PATH:+:}$NIX_PATH";
|
2021-05-11 02:14:42 +02:00
|
|
|
TERMINFO_DIRS =
|
|
|
|
"${profileDirectory}/share/terminfo:$TERMINFO_DIRS\${TERMINFO_DIRS:+:}${distroTerminfoDirs}";
|
2020-04-05 16:46:55 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|