git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #138207 from rnhmjoj/layouts

nixos/extra-layouts: avoid all rebuilds

commit1cf01b5215032228c9a3c7860adde5ee0e0cc160 authorMichele Guerini Rocco <rnhmjoj@users.noreply.github.com> dateSun 19 Sep 2021, 01:10 (5 years ago) parented55c1a3026ff1
5 files changed+24−47
nixos/doc/manual/from_md/release-notes/rl-2111.section.xml+8 nixos/doc/manual/release-notes/rl-2111.section.md+2 nixos/modules/config/console.nix+5−1 nixos/modules/services/x11/extra-layouts.nix+6−46 nixos/modules/services/x11/xserver.nix+3
nixos/doc/manual/from_md/release-notes/rl-2111.section.xml+8
@@ -1049,6 +1049,14 @@ Superuser created successfully.
10491049 attempts from the SSH logs.
10501050 </para>
10511051 </listitem>
1052+ <listitem>
1053+ <para>
1054+ The
1055+ <link xlink:href="options.html#opt-services.xserver.extraLayouts"><literal>services.xserver.extraLayouts</literal></link>
1056+ no longer cause additional rebuilds when a layout is added or
1057+ modified.
1058+ </para>
1059+ </listitem>
10521060 <listitem>
10531061 <para>
10541062 Sway: The terminal emulator <literal>rxvt-unicode</literal> is
nixos/doc/manual/release-notes/rl-2111.section.md+2
@@ -319,6 +319,8 @@ To be able to access the web UI this port needs to be opened in the firewall.
319319
320320 However, if [`services.fail2ban.enable`](options.html#opt-services.fail2ban.enable) is `true`, the `fail2ban` will override the verbosity to `"VERBOSE"`, so that `fail2ban` can observe the failed login attempts from the SSH logs.
321321
322+- The [`services.xserver.extraLayouts`](options.html#opt-services.xserver.extraLayouts) no longer cause additional rebuilds when a layout is added or modified.
323+
322324- Sway: The terminal emulator `rxvt-unicode` is no longer installed by default via `programs.sway.extraPackages`. The current default configuration uses `alacritty` (and soon `foot`) so this is only an issue when using a customized configuration and not installing `rxvt-unicode` explicitly.
323325
324326- `python3` now defaults to Python 3.9. Python 3.9 introduces many deprecation warnings, please look at the [What's New In Python 3.9 post](https://docs.python.org/3/whatsnew/3.9.html) for more information.
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 '');