2017-06-27 10:57:44 +02:00
|
|
|
# This module manages the terminfo database
|
|
|
|
# and its integration in the system.
|
2021-10-05 14:33:18 +03:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2017-06-27 10:57:44 +02:00
|
|
|
{
|
2021-10-05 14:33:18 +03:00
|
|
|
|
2023-09-04 23:05:00 +00:00
|
|
|
options = with lib; {
|
2024-08-27 20:42:49 +02:00
|
|
|
environment.enableAllTerminfo = lib.mkOption {
|
2023-09-04 23:05:00 +00:00
|
|
|
default = false;
|
2024-08-27 20:42:49 +02:00
|
|
|
type = lib.types.bool;
|
2023-09-04 23:05:00 +00:00
|
|
|
description = ''
|
|
|
|
Whether to install all terminfo outputs
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-08-27 20:42:49 +02:00
|
|
|
security.sudo.keepTerminfo = lib.mkOption {
|
2023-10-22 17:58:58 +00:00
|
|
|
default = true;
|
2024-08-27 20:42:49 +02:00
|
|
|
type = lib.types.bool;
|
2023-09-04 23:05:00 +00:00
|
|
|
description = ''
|
|
|
|
Whether to preserve the `TERMINFO` and `TERMINFO_DIRS`
|
|
|
|
environment variables, for `root` and the `wheel` group.
|
|
|
|
'';
|
|
|
|
};
|
2021-10-05 14:33:18 +03:00
|
|
|
};
|
|
|
|
|
2017-06-27 10:57:44 +02:00
|
|
|
config = {
|
|
|
|
|
2024-10-02 05:45:28 +02:00
|
|
|
# This should not contain packages that are broken or can't build, since it
|
|
|
|
# will break this expression
|
|
|
|
#
|
2023-09-09 08:21:59 +00:00
|
|
|
# can be generated with:
|
2024-08-27 20:42:49 +02:00
|
|
|
# lib.attrNames (lib.filterAttrs
|
|
|
|
# (_: drv: (builtins.tryEval (lib.isDerivation drv && drv ? terminfo)).value)
|
2023-09-09 08:21:59 +00:00
|
|
|
# pkgs)
|
2024-10-02 05:45:28 +02:00
|
|
|
environment.systemPackages = lib.mkIf config.environment.enableAllTerminfo (
|
|
|
|
map (x: x.terminfo) (
|
|
|
|
with pkgs.pkgsBuildBuild;
|
|
|
|
[
|
|
|
|
alacritty
|
2024-11-27 12:11:11 +02:00
|
|
|
contour
|
2024-10-02 05:45:28 +02:00
|
|
|
foot
|
2024-12-27 21:04:47 -06:00
|
|
|
ghostty
|
2024-10-02 05:45:28 +02:00
|
|
|
kitty
|
|
|
|
mtm
|
|
|
|
rio
|
|
|
|
rxvt-unicode-unwrapped
|
|
|
|
rxvt-unicode-unwrapped-emoji
|
|
|
|
st
|
|
|
|
termite
|
|
|
|
tmux
|
|
|
|
wezterm
|
|
|
|
yaft
|
|
|
|
]
|
|
|
|
)
|
|
|
|
);
|
2021-10-05 14:33:18 +03:00
|
|
|
|
2017-06-27 10:57:44 +02:00
|
|
|
environment.pathsToLink = [
|
|
|
|
"/share/terminfo"
|
|
|
|
];
|
|
|
|
|
2019-08-13 21:52:01 +00:00
|
|
|
environment.etc.terminfo = {
|
2017-06-27 10:57:44 +02:00
|
|
|
source = "${config.system.path}/share/terminfo";
|
|
|
|
};
|
|
|
|
|
2019-09-11 06:39:05 -04:00
|
|
|
environment.profileRelativeSessionVariables = {
|
2017-06-27 10:57:44 +02:00
|
|
|
TERMINFO_DIRS = [ "/share/terminfo" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.extraInit = ''
|
|
|
|
|
|
|
|
# reset TERM with new TERMINFO available (if any)
|
|
|
|
export TERM=$TERM
|
|
|
|
'';
|
|
|
|
|
2025-03-02 17:42:18 +01:00
|
|
|
security =
|
|
|
|
let
|
|
|
|
extraConfig = ''
|
2017-06-27 10:57:44 +02:00
|
|
|
|
2025-03-02 17:42:18 +01:00
|
|
|
# Keep terminfo database for root and %wheel.
|
|
|
|
Defaults:root,%wheel env_keep+=TERMINFO_DIRS
|
|
|
|
Defaults:root,%wheel env_keep+=TERMINFO
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
lib.mkIf config.security.sudo.keepTerminfo {
|
|
|
|
sudo = { inherit extraConfig; };
|
|
|
|
sudo-rs = { inherit extraConfig; };
|
|
|
|
};
|
2017-06-27 10:57:44 +02:00
|
|
|
};
|
|
|
|
}
|