diff options
Diffstat (limited to 'modules/services/x11/xserver.nix')
-rw-r--r-- | modules/services/x11/xserver.nix | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/modules/services/x11/xserver.nix b/modules/services/x11/xserver.nix index bfdeef81f206..d78a8787e79c 100644 --- a/modules/services/x11/xserver.nix +++ b/modules/services/x11/xserver.nix @@ -43,6 +43,36 @@ let pkgs.xorg.fontadobe75dpi ]; + # Just enumerate all heads without discarding XRandR output information. + xrandrHeads = let + mkHead = num: output: { + name = "multihead${toString num}"; + inherit output; + }; + in imap mkHead cfg.xrandrHeads; + + xrandrDeviceSection = flip concatMapStrings xrandrHeads (h: '' + Option "monitor-${h.output}" "${h.name}" + ''); + + # Here we chain every monitor from the left to right, so we have: + # m4 right of m3 right of m2 right of m1 .----.----.----.----. + # Which will end up in reverse ----------> | m1 | m2 | m3 | m4 | + # `----^----^----^----' + xrandrMonitorSections = let + mkMonitor = previous: current: previous ++ singleton { + inherit (current) name; + value = '' + Section "Monitor" + Identifier "${current.name}" + ${optionalString (previous != []) '' + Option "RightOf" "${(head previous).name}" + ''} + EndSection + ''; + }; + monitors = foldl mkMonitor [] xrandrHeads; + in concatMapStrings (getAttr "value") monitors; configFile = pkgs.stdenv.mkDerivation { name = "xserver.conf"; @@ -256,6 +286,21 @@ in description = "Contents of the first Monitor section of the X server configuration file."; }; + xrandrHeads = mkOption { + default = []; + example = [ "HDMI-0" "DVI-0" ]; + type = with types; listOf string; + description = '' + Simple multiple monitor configuration, just specify a list of XRandR + outputs which will be mapped from left to right in the order of the + list. + + Be careful using this option with multiple graphic adapters or with + drivers that have poor support for XRandR, unexpected things might + happen with those. + ''; + }; + moduleSection = mkOption { default = ""; example = @@ -530,6 +575,7 @@ in Identifier "Device-${driver.name}[0]" Driver "${driver.driverName}" ${cfg.deviceSection} + ${xrandrDeviceSection} EndSection Section "Screen" @@ -572,6 +618,7 @@ in EndSection '')} + ${xrandrMonitorSections} ${cfg.extraXorgOptions} ''; |