I am trying to add a new keyboard layout. I have the following snippet.
system.replaceRuntimeDependencies =
let
xkeyboardconfig = pkgs.xorg.xkeyboardconfig_custom {
layouts =
let
default-layout = {
description = "";
symbolsFile = null;
languages = [ "eng" ];
compatFile = null;
geometryFile = null;
keycodesFile = null;
typesFile = null;
};
in
{
bsk = default-layout // {
description = "BSK";
symbolsFile = ./layouts/bsk;
};
};
};
xorgserver = pkgs.xorg.xorgserver.overrideAttrs (old: {
configureFlags = old.configureFlags ++ [
"--with-xkb-bin-directory=${xkbcomp}/bin"
"--with-xkb-path=${xkeyboardconfig}/share/X11/xkb"
];
});
setxkbmap = pkgs.xorg.setxkbmap.overrideAttrs (old: {
postInstall =
''
mkdir -p $out/share
ln -sfn ${xkeyboardconfig}/etc/X11 $out/share/X11
'';
});
xkbcomp = pkgs.xorg.xkbcomp.overrideAttrs (old: {
configureFlags = [
"--with-xkb-config-root=${xkeyboardconfig}/share/X11/xkb"
];
});
in
[
{
original = pkgs.xorg.xkeyboardconfig;
replacement = xkeyboardconfig;
}
{
original = pkgs.xorg.xorgserver;
replacement = xorgserver;
}
{
original = pkgs.xorg.setxkbmap;
replacement = setxkbmap;
}
{
original = pkgs.xorg.xkbcomp;
replacement = xkbcomp;
}
];
The problem is that when I then run setxkbmap bsk
, it returns Error loading new keyboard description
.
Digging into configuration, I have located the origin of the failure. There are actually two setxkbmap
derivations. One, whose share/X11/xkb/symbols/
contains a file named bsk
, one which does not. They are both built when I run nixos-rebuild test
, and they are both kept when I run nix-collect-garbage
.
When I run nix show-derivation nixpkgs.xorg.setxkbmap
, the out
path points to the derivation which does not contain the bsk
file.
How do I fix this? How can I make setxkbmap
find bsk
?