git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/extra-layouts: avoid all rebuilds

Just setting the XKB_CONFIG_ROOT should be enough, so we don't need to rebuild the xserver, xkbcomp and other packages anymore. However, the variable has to be passed explicitely to scripts running at build time: in particular to xkbvalidate and xkb-console-keymap.

commite4da1edf8b6290c406051454820be7017ec2d7dc authorrnhmjoj <rnhmjoj@inventati.org> dateFri 17 Sep 2021, 01:39 (5 years ago) parent2a58c79
3 files changed+14−47
nixos/modules/config/console.nix+5−1 nixos/modules/services/x11/extra-layouts.nix+6−46 nixos/modules/services/x11/xserver.nix+3
nixos/modules/config/console.nix+5−1
@@ -116,7 +116,11 @@ in
116116 { console.keyMap = with config.services.xserver;
117117 mkIf cfg.useXkbConfig
118118 (pkgs.runCommand "xkb-console-keymap" { preferLocalBuild = true; } ''
119− '${pkgs.ckbcomp}/bin/ckbcomp' -model '${xkbModel}' -layout '${layout}' \
119+ '${pkgs.ckbcomp}/bin/ckbcomp' \
120+ ${optionalString (config.environment.sessionVariables ? XKB_CONFIG_ROOT)
121+ "-I${config.environment.sessionVariables.XKB_CONFIG_ROOT}"
122+ } \
123+ -model '${xkbModel}' -layout '${layout}' \
120124 -option '${xkbOptions}' -variant '${xkbVariant}' > "$out"
121125 '');
122126 }
nixos/modules/services/x11/extra-layouts.nix+6−46
@@ -79,6 +79,10 @@ let
7979 };
8080 };
8181
82+ xkb_patched = pkgs.xorg.xkeyboardconfig_custom {
83+ layouts = config.services.xserver.extraLayouts;
84+ };
85+
8286in
8387
8488{
@@ -114,58 +118,14 @@ in
114118
115119 config = mkIf (layouts != { }) {
116120
117− # We don't override xkeyboard_config directly to
118− # reduce the amount of packages to be recompiled.
119− # Only the following packages are necessary to set
120− # a custom layout anyway:
121− nixpkgs.overlays = lib.singleton (self: super: {
122−
123− xkb_patched = self.xorg.xkeyboardconfig_custom {
124− layouts = config.services.xserver.extraLayouts;
125− };
126−
127− xorg = super.xorg // {
128− xorgserver = super.xorg.xorgserver.overrideAttrs (old: {
129− configureFlags = old.configureFlags ++ [
130− "--with-xkb-bin-directory=${self.xorg.xkbcomp}/bin"
131− "--with-xkb-path=${self.xkb_patched}/share/X11/xkb"
132− ];
133− });
134−
135− setxkbmap = super.xorg.setxkbmap.overrideAttrs (old: {
136− postInstall =
137− ''
138− mkdir -p $out/share
139− ln -sfn ${self.xkb_patched}/etc/X11 $out/share/X11
140− '';
141− });
142−
143− xkbcomp = super.xorg.xkbcomp.overrideAttrs (old: {
144− configureFlags = [ "--with-xkb-config-root=${self.xkb_patched}/share/X11/xkb" ];
145− });
146−
147− };
148−
149− ckbcomp = super.ckbcomp.override {
150− xkeyboard_config = self.xkb_patched;
151− };
152−
153− xkbvalidate = super.xkbvalidate.override {
154− libxkbcommon = self.libxkbcommon.override {
155− xkeyboard_config = self.xkb_patched;
156− };
157− };
158−
159− });
160−
161121 environment.sessionVariables = {
162122 # runtime override supported by multiple libraries e. g. libxkbcommon
163123 # https://xkbcommon.org/doc/current/group__include-path.html
164− XKB_CONFIG_ROOT = "${pkgs.xkb_patched}/etc/X11/xkb";
124+ XKB_CONFIG_ROOT = "${xkb_patched}/etc/X11/xkb";
165125 };
166126
167127 services.xserver = {
168− xkbDir = "${pkgs.xkb_patched}/etc/X11/xkb";
128+ xkbDir = "${xkb_patched}/etc/X11/xkb";
169129 exportConfiguration = config.services.xserver.displayManager.startx.enable
170130 || config.services.xserver.displayManager.sx.enable;
171131 };
nixos/modules/services/x11/xserver.nix+3
@@ -738,6 +738,9 @@ in
738738 nativeBuildInputs = with pkgs.buildPackages; [ xkbvalidate ];
739739 preferLocalBuild = true;
740740 } ''
741+ ${optionalString (config.environment.sessionVariables ? XKB_CONFIG_ROOT)
742+ "export XKB_CONFIG_ROOT=${config.environment.sessionVariables.XKB_CONFIG_ROOT}"
743+ }
741744 xkbvalidate "$xkbModel" "$layout" "$xkbVariant" "$xkbOptions"
742745 touch "$out"
743746 '');