summary refs log tree commit diff
diff options
context:
space:
mode:
authorYureka <yuka@yuka.dev>2022-09-08 23:11:45 +0200
committerYureka <yuka@yuka.dev>2022-09-08 23:11:45 +0200
commitbb5b6029aa2303104f2f15af83068a4663a91f09 (patch)
tree59f93552f8fc388f4c2547eeb3d5a9c315f3e829
parentc881fdb0599c93b377e20812405c0e8f698893d4 (diff)
downloadnixpkgs-bb5b6029aa2303104f2f15af83068a4663a91f09.tar
nixpkgs-bb5b6029aa2303104f2f15af83068a4663a91f09.tar.gz
nixpkgs-bb5b6029aa2303104f2f15af83068a4663a91f09.tar.bz2
nixpkgs-bb5b6029aa2303104f2f15af83068a4663a91f09.tar.lz
nixpkgs-bb5b6029aa2303104f2f15af83068a4663a91f09.tar.xz
nixpkgs-bb5b6029aa2303104f2f15af83068a4663a91f09.tar.zst
nixpkgs-bb5b6029aa2303104f2f15af83068a4663a91f09.zip
Revert "nixos/console: detect unicode properly"
This reverts commit 05958b228b49cfe97f7faf51de4aaf3ede31894e.

Issue https://github.com/NixOS/nixpkgs/issues/188998 is concerns quite a
few NixOS users with full disk encryption and custom keymap.
Since there hasn't been a proper fix agreed upon and merged, I am
reverting this.
The changes can be applied again, when it is ensured that they do not
break custom keymaps in initrd.
-rw-r--r--nixos/modules/config/console.nix26
1 files changed, 6 insertions, 20 deletions
diff --git a/nixos/modules/config/console.nix b/nixos/modules/config/console.nix
index 89b75184c5d..1f8f80a554d 100644
--- a/nixos/modules/config/console.nix
+++ b/nixos/modules/config/console.nix
@@ -8,23 +8,14 @@ let
 
   makeColor = i: concatMapStringsSep "," (x: "0x" + substring (2*i) 2 x);
 
-  isUnicode = '' \
-    LOCALE_ARCHIVE=${config.i18n.glibcLocales}/lib/locale/locale-archive \
-    LANG=${config.i18n.defaultLocale} \
-    LC_IDENTIFICATION=${config.i18n.defaultLocale} \
-    locale -k identification-codeset | grep -i UTF-8 \
-  '';
+  isUnicode = hasSuffix "UTF-8" (toUpper config.i18n.defaultLocale);
 
   optimizedKeymap = pkgs.runCommand "keymap" {
-    nativeBuildInputs = with pkgs.buildPackages; [ kbd locale ];
+    nativeBuildInputs = [ pkgs.buildPackages.kbd ];
     LOADKEYS_KEYMAP_PATH = "${consoleEnv pkgs.kbd}/share/keymaps/**";
     preferLocalBuild = true;
   } ''
-    if ${isUnicode} ; then
-      loadkeys -b -u "${cfg.keyMap}" > $out
-    else
-      loadkeys -b "${cfg.keyMap}" > $out
-    fi
+    loadkeys -b ${optionalString isUnicode "-u"} "${cfg.keyMap}" > $out
   '';
 
   # Sadly, systemd-vconsole-setup doesn't support binary keymaps.
@@ -139,7 +130,7 @@ in
     })
 
     (mkIf setVconsole (mkMerge [
-      { environment.systemPackages = with pkgs; [ kbd locale ];
+      { environment.systemPackages = [ pkgs.kbd ];
 
         # Let systemd-vconsole-setup.service do the work of setting up the
         # virtual consoles.
@@ -148,13 +139,8 @@ in
         environment.etc.kbd.source = "${consoleEnv pkgs.kbd}/share";
 
         boot.initrd.preLVMCommands = mkIf (!config.boot.initrd.systemd.enable) (mkBefore ''
-          if ${isUnicode} ; then
-            kbd_mode -u -C /dev/console
-            printf "\033%%G" >> /dev/console
-          else
-            kbd_mode -a -C /dev/console
-            printf "\033%%@" >> /dev/console
-          fi
+          kbd_mode ${if isUnicode then "-u" else "-a"} -C /dev/console
+          printf "\033%%${if isUnicode then "G" else "@"}" >> /dev/console
           loadkmap < ${optimizedKeymap}
 
           ${optionalString cfg.earlySetup ''