From a99b82b987912337e2041d3717fb36f7da89a529 Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Fri, 10 Oct 2008 16:45:56 +0000 Subject: [PATCH] Misspelling the video driver name results in a thrown message now small refactorings, list of known drivers is an attr set, optional is imported from lib etc svn path=/nixos/trunk/; revision=13048 --- upstart-jobs/xserver.nix | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/upstart-jobs/xserver.nix b/upstart-jobs/xserver.nix index d78c0471f90b..caf842a8e45e 100644 --- a/upstart-jobs/xserver.nix +++ b/upstart-jobs/xserver.nix @@ -6,19 +6,30 @@ let - optional = condition: x: if condition then [x] else []; - + inherit (pkgs.lib) optional isInList getAttr; # Abbreviations. cfg = config.services.xserver; xorg = cfg.package; gnome = pkgs.gnome; stdenv = pkgs.stdenv; + knownVideoDrivers = { + nvidia = { modulesFirst = [ kernelPackages.nvidiaDrivers ]; }; #make sure it first loads the nvidia libs + vesa = { modules = [xorg.xf86videovesa]; }; + vga = { modules = [xorg.xf86videovga]; }; + sis = { modules = [xorg.xf86videosis]; }; + i810 = { modules = [xorg.xf86videoi810]; }; + intel = { modules = [xorg.xf86videointel]; }; + nv = { modules = [xorg.xf86videonv]; }; + ati = { modules = [xorg.xf86videoati]; }; + }; + # Get a bunch of user settings. videoDriver = cfg.videoDriver; resolutions = map (res: ''"${toString res.x}x${toString res.y}"'') (cfg.resolutions); sessionType = cfg.sessionType; + videoDriverModules = getAttr [ videoDriver ] (throw "unkown video driver : \"${videoDriver}\"") knownVideoDrivers; sessionCmd = if sessionType == "" then cfg.sessionStarter else @@ -36,20 +47,14 @@ let modules = - optional (videoDriver == "nvidia") kernelPackages.nvidiaDrivers #make sure it first loads the nvidia libs + + getAttr ["modulesFirst"] [] videoDriverModules ++ [ xorg.xorgserver xorg.xf86inputkeyboard xorg.xf86inputmouse ] - ++ optional (videoDriver == "vesa") xorg.xf86videovesa - ++ optional (videoDriver == "vga") xorg.xf86videovga - ++ optional (videoDriver == "sis") xorg.xf86videosis - ++ optional (videoDriver == "i810") xorg.xf86videoi810 - ++ optional (videoDriver == "intel") xorg.xf86videointel - ++ optional (videoDriver == "nv") xorg.xf86videonv - ++ optional (videoDriver == "ati") xorg.xf86videoati - ++ optional (videoDriver == "radeonhd") xorg.xf86videoradeonhd + ++ getAttr ["modules"] [] videoDriverModules ++ (optional cfg.synaptics.enable ["${pkgs.synaptics}/${xorg.xorgserver}" /*xorg.xf86inputevdev*/]);