diff --git a/nixos/modules/config/terminfo.nix b/nixos/modules/config/terminfo.nix index 66a9d691c6b7..43bb633a1064 100644 --- a/nixos/modules/config/terminfo.nix +++ b/nixos/modules/config/terminfo.nix @@ -66,6 +66,17 @@ source = "${config.system.path}/share/terminfo"; }; + boot.initrd.systemd.contents = lib.listToAttrs ( + lib.map + (ti: lib.nameValuePair "/etc/terminfo/${ti}" { source = "${pkgs.ncurses}/share/terminfo/${ti}"; }) + [ + "l/linux" + "v/vt100" + "v/vt102" + "v/vt220" + ] + ); + environment.profileRelativeSessionVariables = { TERMINFO_DIRS = [ "/share/terminfo" ]; }; diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index b9a72c322a43..7bf9f40d9738 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1560,6 +1560,7 @@ in }; systemd-initrd-simple = runTest ./systemd-initrd-simple.nix; systemd-initrd-swraid = runTest ./systemd-initrd-swraid.nix; + systemd-initrd-terminfo = runTest ./systemd-initrd-terminfo.nix; systemd-initrd-vconsole = runTest ./systemd-initrd-vconsole.nix; systemd-initrd-vlan = runTest ./systemd-initrd-vlan.nix; systemd-journal = runTest ./systemd-journal.nix; diff --git a/nixos/tests/systemd-initrd-terminfo.nix b/nixos/tests/systemd-initrd-terminfo.nix new file mode 100644 index 000000000000..24870eaf428a --- /dev/null +++ b/nixos/tests/systemd-initrd-terminfo.nix @@ -0,0 +1,22 @@ +{ lib, ... }: +{ + name = "systemd-initrd-terminfo"; + + meta.maintainers = [ lib.maintainers.elvishjerricco ]; + + nodes.machine = + { config, ... }: + { + boot.initrd.systemd = { + enable = true; + extraBin.script = "${config.boot.initrd.systemd.package.util-linux}/bin/script"; + }; + testing.initrdBackdoor = true; + }; + + testScript = '' + machine.wait_for_unit("initrd.target") + rc, out = machine.execute("echo q | script -q -e -c 'yes | less' /dev/null") + assert "terminals database is inaccessible" not in out + ''; +}