diff options
author | rnhmjoj <rnhmjoj@inventati.org> | 2019-11-22 11:50:46 +0100 |
---|---|---|
committer | rnhmjoj <rnhmjoj@inventati.org> | 2019-12-20 00:27:35 +0100 |
commit | a35b12ed215e3b978ba4f14eca7bdcc11d2bf70c (patch) | |
tree | 91d92ad1fa045c4757f1d4227d73eb53561f2811 /nixos/modules/config/console.nix | |
parent | 9802bc5b32291639e3b189ded2c0fa61666bb54e (diff) | |
download | nixpkgs-a35b12ed215e3b978ba4f14eca7bdcc11d2bf70c.tar nixpkgs-a35b12ed215e3b978ba4f14eca7bdcc11d2bf70c.tar.gz nixpkgs-a35b12ed215e3b978ba4f14eca7bdcc11d2bf70c.tar.bz2 nixpkgs-a35b12ed215e3b978ba4f14eca7bdcc11d2bf70c.tar.lz nixpkgs-a35b12ed215e3b978ba4f14eca7bdcc11d2bf70c.tar.xz nixpkgs-a35b12ed215e3b978ba4f14eca7bdcc11d2bf70c.tar.zst nixpkgs-a35b12ed215e3b978ba4f14eca7bdcc11d2bf70c.zip |
nixos/console: set colors using kernel parameters
This commit changes the console colors implementation to use the kernel parameters instead of relying on terminal escape sequences. This means the palette is applied by the kernel itself with no custom code running in the initrd and works for all virtual terminals (not only tty0).
Diffstat (limited to 'nixos/modules/config/console.nix')
-rw-r--r-- | nixos/modules/config/console.nix | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/nixos/modules/config/console.nix b/nixos/modules/config/console.nix index a524aa3adcd..f662ed62d31 100644 --- a/nixos/modules/config/console.nix +++ b/nixos/modules/config/console.nix @@ -6,10 +6,7 @@ with lib; let cfg = config.console; - makeColor = n: value: "COLOR_${toString n}=${value}"; - makeColorCS = - let positions = [ "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F" ]; - in n: value: "\\033]P${elemAt positions (n - 1)}${value}"; + makeColor = i: concatMapStringsSep "," (x: "0x" + substring (2*i) 2 x); isUnicode = hasSuffix "UTF-8" (toUpper config.i18n.defaultLocale); @@ -25,7 +22,6 @@ let vconsoleConf = pkgs.writeText "vconsole.conf" '' KEYMAP=${cfg.keyMap} FONT=${cfg.font} - ${concatImapStringsSep "\n" makeColor cfg.colors} ''; consoleEnv = pkgs.buildEnv { @@ -160,10 +156,6 @@ in ${optionalString cfg.earlySetup '' setfont -C /dev/console $extraUtils/share/consolefonts/font.psf ''} - - ${concatImapStringsSep "\n" (n: color: '' - printf "${makeColorCS n color}" >> /dev/console - '') cfg.colors} ''; systemd.services.systemd-vconsole-setup = @@ -173,6 +165,14 @@ in }; } + (mkIf (cfg.colors != []) { + boot.kernelParams = [ + "vt.default_red=${makeColor 0 cfg.colors}" + "vt.default_grn=${makeColor 1 cfg.colors}" + "vt.default_blu=${makeColor 2 cfg.colors}" + ]; + }) + (mkIf cfg.earlySetup { boot.initrd.extraUtilsCommands = '' mkdir -p $out/share/consolefonts |