1# This module manages the terminfo database
2# and its integration in the system.
3{ config, lib, pkgs, ... }:
4
5with lib;
6
7{
8
9 options.environment.enableAllTerminfo = with lib; mkOption {
10 default = false;
11 type = types.bool;
12 description = lib.mdDoc ''
13 Whether to install all terminfo outputs
14 '';
15 };
16
17 config = {
18
19 # can be generated with: filter (drv: (builtins.tryEval (drv ? terminfo)).value) (attrValues pkgs)
20 environment.systemPackages = mkIf config.environment.enableAllTerminfo (map (x: x.terminfo) (with pkgs; [
21 alacritty
22 foot
23 kitty
24 mtm
25 rxvt-unicode-unwrapped
26 rxvt-unicode-unwrapped-emoji
27 termite
28 wezterm
29 ]));
30
31 environment.pathsToLink = [
32 "/share/terminfo"
33 ];
34
35 environment.etc.terminfo = {
36 source = "${config.system.path}/share/terminfo";
37 };
38
39 environment.profileRelativeSessionVariables = {
40 TERMINFO_DIRS = [ "/share/terminfo" ];
41 };
42
43 environment.extraInit = ''
44
45 # reset TERM with new TERMINFO available (if any)
46 export TERM=$TERM
47 '';
48
49 security.sudo.extraConfig = ''
50
51 # Keep terminfo database for root and %wheel.
52 Defaults:root,%wheel env_keep+=TERMINFO_DIRS
53 Defaults:root,%wheel env_keep+=TERMINFO
54 '';
55
56 };
57}