diff --git a/nixos/modules/config/terminfo.nix b/nixos/modules/config/terminfo.nix index 1396640af67..693404a429c 100644 --- a/nixos/modules/config/terminfo.nix +++ b/nixos/modules/config/terminfo.nix @@ -1,9 +1,33 @@ # This module manages the terminfo database # and its integration in the system. -{ config, ... }: +{ config, lib, pkgs, ... }: + +with lib; + { + + options.environment.enableAllTerminfo = with lib; mkOption { + default = false; + type = types.bool; + description = '' + Whether to install all terminfo outputs + ''; + }; + config = { + # can be generated with: filter (drv: (builtins.tryEval (drv ? terminfo)).value) (attrValues pkgs) + environment.systemPackages = mkIf config.environment.enableAllTerminfo (map (x: x.terminfo) (with pkgs; [ + alacritty + foot + kitty + mtm + rxvt-unicode-unwrapped + rxvt-unicode-unwrapped-emoji + termite + wezterm + ])); + environment.pathsToLink = [ "/share/terminfo" ]; diff --git a/nixos/tests/all-terminfo.nix b/nixos/tests/all-terminfo.nix new file mode 100644 index 00000000000..dd47c66ee1c --- /dev/null +++ b/nixos/tests/all-terminfo.nix @@ -0,0 +1,31 @@ +import ./make-test-python.nix ({ pkgs, ... }: rec { + name = "all-terminfo"; + meta = with pkgs.lib.maintainers; { + maintainers = [ jkarlson ]; + }; + + nodes.machine = { pkgs, config, lib, ... }: + let + infoFilter = name: drv: + let + o = builtins.tryEval drv; + in + o.success && lib.isDerivation o.value && o.value ? outputs && builtins.elem "terminfo" o.value.outputs; + terminfos = lib.filterAttrs infoFilter pkgs; + excludedTerminfos = lib.filterAttrs (_: drv: !(builtins.elem drv.terminfo config.environment.systemPackages)) terminfos; + includedOuts = lib.filterAttrs (_: drv: builtins.elem drv.out config.environment.systemPackages) terminfos; + in + { + environment = { + enableAllTerminfo = true; + etc."terminfo-missing".text = builtins.concatStringsSep "\n" (builtins.attrNames excludedTerminfos); + etc."terminfo-extra-outs".text = builtins.concatStringsSep "\n" (builtins.attrNames includedOuts); + }; + }; + + testScript = + '' + machine.fail("grep . /etc/terminfo-missing >&2") + machine.fail("grep . /etc/terminfo-extra-outs >&2") + ''; +}) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 0a735291353..a1d4e284657 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -35,6 +35,7 @@ in agate = handleTest ./web-servers/agate.nix {}; agda = handleTest ./agda.nix {}; airsonic = handleTest ./airsonic.nix {}; + allTerminfo = handleTest ./all-terminfo.nix {}; amazon-init-shell = handleTest ./amazon-init-shell.nix {}; apfs = handleTest ./apfs.nix {}; apparmor = handleTest ./apparmor.nix {}; diff --git a/pkgs/applications/terminal-emulators/wezterm/default.nix b/pkgs/applications/terminal-emulators/wezterm/default.nix index 17ee157a440..c51aee52686 100644 --- a/pkgs/applications/terminal-emulators/wezterm/default.nix +++ b/pkgs/applications/terminal-emulators/wezterm/default.nix @@ -100,7 +100,10 @@ rustPlatform.buildRustPackage rec { ln -s $out/bin/{wezterm,wezterm-mux-server,wezterm-gui,strip-ansi-escapes} "$OUT_APP" ''; - passthru.tests.test = nixosTests.terminal-emulators.wezterm; + passthru.tests = { + all-terminfo = nixosTests.allTerminfo; + test = nixosTests.terminal-emulators.wezterm; + }; meta = with lib; { description = "A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust";