From d97cdfc591baf790ce5a9836e1503dfb0eb152e6 Mon Sep 17 00:00:00 2001
From: aszlig <aszlig@redmoonstudios.org>
Date: Mon, 3 Jul 2017 07:33:35 +0200
Subject: [PATCH] nixos/xserver: Document the layouts sed expression

This was brought up by @0xABAB in #26984 by the following comment:

https://github.com/NixOS/nixpkgs/pull/26984#discussion_r125146405

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
---
 nixos/modules/services/x11/xserver.nix | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/nixos/modules/services/x11/xserver.nix b/nixos/modules/services/x11/xserver.nix
index 01bab8fccadb..504a6b79d577 100644
--- a/nixos/modules/services/x11/xserver.nix
+++ b/nixos/modules/services/x11/xserver.nix
@@ -652,6 +652,10 @@ in
       inherit (cfg) layout xkbDir;
     } ''
       if 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