diff --git a/system/options.nix b/system/options.nix index f468b804744..622388d3532 100644 --- a/system/options.nix +++ b/system/options.nix @@ -452,6 +452,25 @@ } + { + name = ["services" "xserver" "resolutions"]; + default = [{x = 1024; y = 768;} {x = 800; y = 600;} {x = 640; y = 480;}]; + description = " + The screen resolutions for the X server. The first element is the default resolution. + "; + } + + + { + name = ["services" "xserver" "videoDriver"]; + default = "vesa"; + example = "i810"; + description = " + The name of the video driver for your graphics card. + "; + } + + { name = ["services" "httpd" "enable"]; default = false; @@ -461,6 +480,7 @@ } + /* { name = ["services" "httpd" "user"]; default = "wwwrun"; @@ -617,6 +637,7 @@ Extra subservices to enable in the webserver. "; } + */ { name = ["installer" "nixpkgsURL"]; diff --git a/system/upstart.nix b/system/upstart.nix index b295e14c3e5..dac913d4e57 100644 --- a/system/upstart.nix +++ b/system/upstart.nix @@ -118,6 +118,7 @@ import ../upstart-jobs/gather.nix { # X server. ++ optional ["services" "xserver" "enable"] (import ../upstart-jobs/xserver.nix { + inherit config; inherit (pkgs) stdenv writeText lib xterm slim xorg; fontDirectories = import ./fonts.nix {inherit pkgs;}; }) diff --git a/upstart-jobs/xserver.conf b/upstart-jobs/xserver.conf index 17aa3d3fd88..d092464d8a3 100644 --- a/upstart-jobs/xserver.conf +++ b/upstart-jobs/xserver.conf @@ -9,7 +9,6 @@ EndSection Section "ServerFlags" Option "AllowMouseOpenFail" "on" - Option "DontVTSwitch" "off" EndSection @@ -37,12 +36,8 @@ EndSection Section "Monitor" Identifier "Monitor[0]" Option "DPMS" - UseModes "Modes[0]" -EndSection - - -Section "Modes" - Identifier "Modes[0]" + HorizSync 28-49 + VertRefresh 43-75 EndSection @@ -53,14 +48,14 @@ Section "Screen" DefaultDepth 16 SubSection "Display" Depth 16 - Modes "1024x768" + Modes @resolutions@ EndSubSection EndSection Section "Device" Identifier "Device[0]" - Driver "vesa" + Driver "@videoDriver@" EndSection @@ -70,4 +65,3 @@ Section "ServerLayout" InputDevice "Mouse[0]" "CorePointer" Screen "Screen[0]" EndSection - diff --git a/upstart-jobs/xserver.nix b/upstart-jobs/xserver.nix index 1eae577f162..f5482013714 100644 --- a/upstart-jobs/xserver.nix +++ b/upstart-jobs/xserver.nix @@ -1,5 +1,7 @@ { stdenv, writeText, lib, xorg, xterm, slim +, config + , # Virtual console for the X server. tty ? 7 @@ -13,17 +15,29 @@ let - drivers = [ + getCfg = option: config.get ["services" "xserver" option]; + + optional = condition: x: if condition then [x] else []; + + + videoDriver = getCfg "videoDriver"; + + resolutions = map (res: "\"${toString res.x}x${toString res.y}\"") (getCfg "resolutions"); + + + modules = [ xorg.xorgserver xorg.xf86inputkeyboard xorg.xf86inputmouse - xorg.xf86videovesa - ]; + ] + ++ optional (videoDriver == "vesa") xorg.xf86videovesa + ++ optional (videoDriver == "i810") xorg.xf86videoi810; - config = stdenv.mkDerivation { + + configFile = stdenv.mkDerivation { name = "xserver.conf"; src = ./xserver.conf; - inherit fontDirectories; + inherit fontDirectories videoDriver resolutions; buildCommand = " buildCommand= # urgh, don't substitute this @@ -37,7 +51,7 @@ let done export modulePaths= - for i in $(find ${toString drivers} -type d); do + for i in $(find ${toString modules} -type d); do if ls $i/*.so 2> /dev/null; then modulePaths=\"\${modulePaths}ModulePath \\\"$i\\\"\\n\" fi @@ -47,17 +61,19 @@ let "; }; + clientScript = writeText "xclient" " ${xorg.twm}/bin/twm & ${xterm}/bin/xterm -ls "; + xserverArgs = [ "-ac" "-nolisten tcp" "-terminate" "-logfile" "/var/log/X.${toString display}.log" - "-config ${config}" + "-config ${configFile}" ":${toString display}" "vt${toString tty}" ]; @@ -69,8 +85,10 @@ xserver_arguments ${toString xserverArgs} login_cmd exec ${stdenv.bash}/bin/sh ${clientScript} "; + in + rec { name = "xserver";