Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 02ce6963045e
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 69da1807f02d
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Jul 3, 2017

  1. nixos/xserver: Document the layouts sed expression

    This was brought up by @0xABAB in #26984 by the following comment:
    
    #26984 (comment)
    
    Signed-off-by: aszlig <aszlig@redmoonstudios.org>
    aszlig committed Jul 3, 2017

    Verified

    This commit was signed with the committer’s verified signature.
    Copy the full SHA
    d97cdfc View commit details
  2. nixos/xserver: Allow more than one keyboard layout

    Regression introduced by 44c64fe.
    
    The services.xserver.layout option allows to specify more than one
    layout separated by comma, which the commit above didn't take into
    account.
    
    This is very similar to @lheckemann's pull request (#26984) but differs
    in the following ways:
    
      * Print out the full list available layouts (as suggested by @0xABAB
        in [1]).
      * Loop over $layout using the default IFS (and thus no need for
        escaping ${cfg.layout}), because the layouts won't contain white
        spaces.
      * Re-do the error message, which now uses multiple echos instead of a
        heredoc, so the line is wrapped according to the viewers terminal
        width.
    
    I've tested this with several good and bad layouts and also against the
    keymap NixOS VM subtests.
    
    [1]: #26984 (comment)
    
    Signed-off-by: aszlig <aszlig@redmoonstudios.org>
    Fixes: #26961
    Closes: #26984
    aszlig committed Jul 3, 2017

    Verified

    This commit was signed with the committer’s verified signature.
    Copy the full SHA
    69da180 View commit details
Showing with 40 additions and 16 deletions.
  1. +40 −16 nixos/modules/services/x11/xserver.nix
56 changes: 40 additions & 16 deletions nixos/modules/services/x11/xserver.nix
Original file line number Diff line number Diff line change
@@ -651,25 +651,49 @@ in
system.extraDependencies = singleton (pkgs.runCommand "xkb-layouts-exist" {
inherit (cfg) layout xkbDir;
} ''
if sed -n -e ':i /^! \(layout\|variant\) *$/ {
# We can use the default IFS here, because the layouts won't contain
# spaces or tabs and are ruled out by the sed expression below.
availableLayouts="$(
sed -n -e ':i /^! \(layout\|variant\) *$/ {
# Loop through all of the layouts/variants until we hit another ! at
# the start of the line or the line is empty ('t' branches only if
# the last substitution was successful, so if the line is empty the
# substition will fail).
:l; n; /^!/bi; s/^ *\([^ ]\+\).*/\1/p; tl
}' "$xkbDir/rules/base.lst" | grep -qxF "$layout"
then
touch "$out"
exit 0
fi
cat >&2 <<-EOF
The selected keyboard layout definition does not exist:
$layout
}' "$xkbDir/rules/base.lst" | sort -u
)"
layoutNotFound() {
echo >&2
echo "The following layouts and variants are available:" >&2
echo >&2
# While an output width of 80 is more desirable for small terminals, we
# really don't know the amount of columns of the terminal from within
# the builder. The content in $availableLayouts however is pretty
# large, so let's opt for a larger width here, because it will print a
# smaller amount of lines on modern KMS/framebuffer terminals and won't
# lose information even in smaller terminals (it only will look a bit
# ugly).
echo "$availableLayouts" | ${pkgs.utillinux}/bin/column -c 150 >&2
echo >&2
echo "However, the keyboard layout definition in" \
"\`services.xserver.layout' contains the layout \`$1', which" \
"isn't a valid layout or variant." >&2
echo >&2
exit 1
}
Set \`services.xserver.layout' to the name of an existing keyboard
layout (check $xkbDir/rules/base.lst for options).
# Again, we don't need to take care of IFS, see the comment for
# $availableLayouts.
for l in ''${layout//,/ }; do
if ! echo "$availableLayouts" | grep -qxF "$l"; then
layoutNotFound "$l"
fi
done
EOF
exit 1
touch "$out"
'');

services.xserver.config =