~kaction/config

ref: c15a3cb21bfffdce7b9fcefc4479fabd6fe43e11 config/system-v2/tty-keymap.nix -rw-r--r-- 1.2 KiB
c15a3cb2 — Dmitry Bogatov nix-sys: mark files created as immutable 1 year, 1 day ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Alpine Linux does not have emacs2 console keymap, the one which makes
# CapsLock key to act like Control key, in standard repositories, so I
# extract it from console-data Debian package.
{ kbd, fetchurl, stdenv, execline, writeScript }:
let
  fetch-deborig = { name, version, sha256, ext ? "bz2" }:
    let
      letter = builtins.substring 0 1 name;
      base = "https://deb.debian.org/debian/pool/main";
      url = "${base}/${letter}/${name}/${name}_${version}.orig.tar.${ext}";
    in fetchurl { inherit url sha256; };

  keymap-emacs2 = stdenv.mkDerivation {
    pname = "keymap-emacs2";
    version = "1.12";
    src = fetch-deborig {
      name = "console-data";
      version = "1.12";
      sha256 = "03k0vbcaclzh25bnz79w7ig74ykfb0ydblync3h7j92a4pq099pi";
    };
    dontConfigure = true;
    dontBuild = true;
    installPhase = ''
      mkdir -p $out
      cp ./keymaps/i386/qwerty/emacs2.kmap $out
      cp ./keymaps/i386/include/linux-with-alt-and-altgr.inc $out
      cp ./keymaps/i386/include/qwerty-layout.inc $out
      cp ./keymaps/i386/include/linux-keys-bare.inc $out
    '';
  };
in writeScript "local.loadkeys" ''
  #!${execline}/bin/execlineb -P
  ${kbd}/bin/loadkeys ${keymap-emacs2}/emacs2.kmap
''