at 24.11-pre 1.7 kB view raw
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 = with lib; { 10 environment.enableAllTerminfo = mkOption { 11 default = false; 12 type = types.bool; 13 description = '' 14 Whether to install all terminfo outputs 15 ''; 16 }; 17 18 security.sudo.keepTerminfo = mkOption { 19 default = true; 20 type = types.bool; 21 description = '' 22 Whether to preserve the `TERMINFO` and `TERMINFO_DIRS` 23 environment variables, for `root` and the `wheel` group. 24 ''; 25 }; 26 }; 27 28 config = { 29 30 # can be generated with: 31 # attrNames (filterAttrs 32 # (_: drv: (builtins.tryEval (isDerivation drv && drv ? terminfo)).value) 33 # pkgs) 34 environment.systemPackages = mkIf config.environment.enableAllTerminfo (map (x: x.terminfo) (with pkgs.pkgsBuildBuild; [ 35 alacritty 36 contour 37 foot 38 kitty 39 mtm 40 rio 41 rxvt-unicode-unwrapped 42 rxvt-unicode-unwrapped-emoji 43 st 44 termite 45 tmux 46 wezterm 47 yaft 48 ])); 49 50 environment.pathsToLink = [ 51 "/share/terminfo" 52 ]; 53 54 environment.etc.terminfo = { 55 source = "${config.system.path}/share/terminfo"; 56 }; 57 58 environment.profileRelativeSessionVariables = { 59 TERMINFO_DIRS = [ "/share/terminfo" ]; 60 }; 61 62 environment.extraInit = '' 63 64 # reset TERM with new TERMINFO available (if any) 65 export TERM=$TERM 66 ''; 67 68 security.sudo.extraConfig = mkIf config.security.sudo.keepTerminfo '' 69 70 # Keep terminfo database for root and %wheel. 71 Defaults:root,%wheel env_keep+=TERMINFO_DIRS 72 Defaults:root,%wheel env_keep+=TERMINFO 73 ''; 74 75 }; 76}