From 5e7a768336c89a3671725ec54e70b1c0a9cf34f2 Mon Sep 17 00:00:00 2001 From: Sander van der Burg Date: Tue, 7 Apr 2009 15:33:59 +0000 Subject: [PATCH 1/3] Added very experimental KDM support svn path=/nixos/trunk/; revision=14913 --- system/options.nix | 9 ++ upstart-jobs/default.nix | 6 + upstart-jobs/kdm.nix | 269 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 284 insertions(+) create mode 100644 upstart-jobs/kdm.nix diff --git a/system/options.nix b/system/options.nix index 9128e794e025..0c0554897ee6 100644 --- a/system/options.nix +++ b/system/options.nix @@ -1191,6 +1191,15 @@ in }; }; + kdm = { + + enable = mkOption { + default = false; + description = " + Whether to enable the KDE display manager. + "; + }; + }; xserver = { diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index 3ecd007dc1c6..9df21fb57a5e 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -236,6 +236,12 @@ let fontDirectories = import ../system/fonts.nix {inherit pkgs config;}; }) + ++ optional config.services.kdm.enable + (import ../upstart-jobs/kdm.nix { + inherit config pkgs kernelPackages; + fontDirectories = import ../system/fonts.nix {inherit pkgs config;}; + }) + # Apache httpd. ++ optional (config.services.httpd.enable && !config.services.httpd.experimental) (import ../upstart-jobs/httpd.nix { diff --git a/upstart-jobs/kdm.nix b/upstart-jobs/kdm.nix new file mode 100644 index 000000000000..a4bae828c2b4 --- /dev/null +++ b/upstart-jobs/kdm.nix @@ -0,0 +1,269 @@ +{config, pkgs, kernelPackages, fontDirectories}: + +let + # Abbreviations. + cfg = config.services.xserver; + xorg = pkgs.xlibs; + + inherit (pkgs.lib) optional isInList getAttr; + stdenv = pkgs.stdenv; + + knownVideoDrivers = { + nvidia = { modulesFirst = [ kernelPackages.nvidia_x11 ]; }; #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]; }; + via = { modules = [xorg.xf86videovia]; }; + cirrus = { modules = [xorg.xf86videocirrus]; }; + }; + + # 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; + + modules = + + getAttr ["modulesFirst"] [] videoDriverModules + ++ [ + xorg.xorgserver + xorg.xf86inputkeyboard + xorg.xf86inputmouse + ] + ++ getAttr ["modules"] [] videoDriverModules + ++ (optional cfg.synaptics.enable ["${pkgs.synaptics}/${xorg.xorgserver}" /*xorg.xf86inputevdev*/]); + + + fontsForXServer = + fontDirectories ++ + # We don't want these fonts in fonts.conf, because then modern, + # fontconfig-based applications will get horrible bitmapped + # Helvetica fonts. It's better to get a substitution (like Nimbus + # Sans) than that horror. But we do need the Adobe fonts for some + # old non-fontconfig applications. (Possibly this could be done + # better using a fontconfig rule.) + [ pkgs.xorg.fontadobe100dpi + pkgs.xorg.fontadobe75dpi + ]; + + configFile = stdenv.mkDerivation { + name = "xserver.conf"; + src = ./xserver.conf; + inherit fontsForXServer videoDriver resolutions; + isClone = if cfg.isClone then "on" else "off"; + + synapticsInputDevice = if cfg.synaptics.enable then '' + Section "InputDevice" + Identifier "Touchpad[0]" + Driver "synaptics" + Option "Device" "${cfg.synaptics.dev}" + Option "Protocol" "PS/2" + Option "LeftEdge" "1700" + Option "RightEdge" "5300" + Option "TopEdge" "1700" + Option "BottomEdge" "4200" + Option "FingerLow" "25" + Option "FingerHigh" "30" + Option "MaxTapTime" "180" + Option "MaxTapMove" "220" + Option "VertScrollDelta" "100" + Option "MinSpeed" "${cfg.synaptics.minSpeed}" + Option "MaxSpeed" "${cfg.synaptics.maxSpeed}" + Option "AccelFactor" "0.0010" + Option "SHMConfig" "on" + Option "Repeater" "/dev/input/mice" + Option "TapButton1" "1" + Option "TapButton2" "2" + Option "TapButton3" "3" + Option "VertTwoFingerScroll" "${if cfg.synaptics.twoFingerScroll then "1" else "0"}" + Option "HorizTwoFingerScroll" "${if cfg.synaptics.twoFingerScroll then "1" else "0"}" + EndSection + '' else ""; + + xkbOptions = if cfg.xkbOptions == "" then "" else '' + Option "XkbOptions" "${cfg.xkbOptions}" + ''; + + xkbModel = cfg.xkbModel; + layout = cfg.layout; + + corePointer = if cfg.synaptics.enable then "Touchpad[0]" else "Mouse[0]"; + + internalAGPGART = + if cfg.useInternalAGPGART == "yes" then + '' Option "UseInternalAGPGART" "yes"'' + else if cfg.useInternalAGPGART == "no" then + '' Option "UseInternalAGPGART" "no"'' + else ""; + + extraDeviceConfig = cfg.extraDeviceConfig; + extraMonitorSettings = cfg.extraMonitorSettings; + extraDisplaySettings = cfg.extraDisplaySettings; + extraModules = cfg.extraModules; + serverLayoutOptions = cfg.serverLayoutOptions; + defaultDepth = cfg.defaultDepth; + virtualScreen = if cfg.virtualScreen != null then + "Virtual ${toString cfg.virtualScreen.x} ${toString cfg.virtualScreen.y}" + else ""; + + xfs = if cfg.useXFS == false then "" else + ''FontPath "${toString cfg.useXFS}"''; + + buildCommand = '' + buildCommand= # urgh, don't substitute this + + export fontPaths= + for i in $fontsForXServer; do + if test "''${i:0:''${#NIX_STORE}}" == "$NIX_STORE"; then + for j in $(find $i -name fonts.dir); do + fontPaths="''${fontPaths}FontPath \"$(dirname $j)\"''\n" + done + fi + done + + export modulePaths= + for i in $(find ${toString modules} -type d); do + if ls $i/*.so* > /dev/null 2>&1; then + modulePaths="''${modulePaths}ModulePath \"$i\"''\n" + fi + done + + export moduleSection="" + export screen="" + export device="" + export extensions="" + + + #if only my gf were this dirty + if test "${toString videoDriver}" == "nvidia"; then + export screen=' + Option "AddARGBGLXVisuals" "true" + Option "DisableGLXRootClipping" "true" + Option "RandRRotation" "on" + ' + + export device=' + Option "RenderAccel" "true" + Option "AllowGLXWithComposite" "true" + Option "AddARGBGLXVisuals" "true" + ' + + export extensions=' + Option "Composite" "Enable" + ' + fi + + if [ "${toString videoDriver}" = i810 ]; then + export extensions=' + Option "Composite" "Enable" + '; + fi; + + if [ "${toString videoDriver}" = ati ]; then + export extensions=' + Option "Composite" "Enable" + '; + fi; + + if [ "${toString videoDriver}" = radeonhd ]; then + export extensions=' + Option "Composite" "Enable" + '; + fi; + + substituteAll $src $out + ''; # */ + }; + + xsession = pkgs.writeText "Xsession" '' + source /etc/profile + + session=$1 + + export PATH=$PATH:${pkgs.xterm}/bin:${pkgs.qt4}/bin:${pkgs.dbus.libs}/bin:${pkgs.kde42.kdelibs}/bin:${pkgs.xlibs.xset}/bin:${pkgs.xlibs.xsetroot}/bin:${pkgs.xlibs.xmessage}/bin:${pkgs.xlibs.xprop}/bin + export XDG_CONFIG_DIRS= + export XDG_DATA_DIRS=${pkgs.shared_mime_info}/share + + case $session in + "") + exec xmessage -center -buttons OK:0 -default OK "Sorry, $DESKTOP_SESSION is no valid session." + ;; + failsafe) + exec xterm -geometry 80x24-0-0 + ;; + custom) + exec $HOME/.xsession + ;; + default) + exec ${pkgs.kde42.kdebase_workspace}/bin/startkde + ;; + *) + eval exec "$session" + ;; + esac + + exec xmessage -center -buttons OK:0 -default OK "Sorry, cannot execute $session. Check $DESKTOP_SESSION.desktop." + ''; + + kdmrc = stdenv.mkDerivation { + name = "kdmrc"; + buildCommand = '' + cp ${pkgs.kde42.kdebase_workspace}/share/config/kdm/kdmrc . + sed -i -e "s|#HaltCmd=|HaltCmd=${pkgs.upstart}/sbin/halt|" \ + -e "s|#RebootCmd=|RebootCmd=${pkgs.upstart}/sbin/reboot|" \ + -e "s|#Xrdb=|Xrdb=${pkgs.xlibs.xrdb}/bin/xrdb|" \ + -e "s|#HiddenUsers=root|HiddenUsers=root,nixbld1,nixbld2,nixbld3,nixbld4,nixbld5,nixbld6,nixbld7,nixbld8,nixbld9,nixbld10|" \ + -e "s|ServerCmd=/FOO/bin/X|ServerCmd=${pkgs.xlibs.xorgserver}/bin/X -config ${configFile} -xkbdir ${pkgs.xkeyboard_config}/etc/X11/xkb|" \ + -e "s|Session=${pkgs.kde42.kdebase_workspace}/share/config/kdm/Xsession|Session=${xsession}|" \ + -e "s|#FailsafeClient=|FailsafeClient=${pkgs.xterm}/bin/xterm|" \ + -e "s|#PluginsLogin=sign|PluginsLogin=${pkgs.kde42.kdebase_workspace}/lib/kde4/kgreet_classic.so|" \ + kdmrc + ensureDir $out + cp kdmrc $out + ''; + }; +in +{ + name = "kdm"; + + job = '' + description "KDE Display Manager" + + start script + + rm -f /var/run/opengl-driver + ${if videoDriver == "nvidia" + then '' + ln -sf ${kernelPackages.nvidia_x11} /var/run/opengl-driver + '' + else if cfg.driSupport + then "ln -sf ${pkgs.mesa} /var/run/opengl-driver" + else "" + } + + rm -f /tmp/.X0-lock + + end script + + ${if videoDriver == "nvidia" + then "env LD_LIBRARY_PATH=${xorg.libX11}/lib:${xorg.libXext}/lib:${kernelPackages.nvidia_x11}/lib" + else "" + } + + ${if videoDriver != "nvidia" + then "env XORG_DRI_DRIVER_PATH=${pkgs.mesa}/lib/modules/dri" + else "" + } + + env FONTCONFIG_FILE=/etc/fonts/fonts.conf # !!! cleanup + env XKB_BINDIR=${xorg.xkbcomp}/bin # Needed for the Xkb extension. + + respawn ${pkgs.kde42.kdebase_workspace}/bin/kdm -config ${kdmrc}/kdmrc + ''; +} From bec0e32034493c6bbf08d70a9342d09565e098a9 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 9 Apr 2009 14:11:55 +0000 Subject: [PATCH 2/3] * Add the programs provided by the acl, attr and libcap libraries to the system path. (They were in the closure already anyway so it doesn't cost us anything.) svn path=/nixos/trunk/; revision=14973 --- system/system.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/system/system.nix b/system/system.nix index 780631130897..43e4bc581565 100644 --- a/system/system.nix +++ b/system/system.nix @@ -182,6 +182,8 @@ rec { setuidWrapper ] ++ pkgs.lib.optionals (!config.environment.cleanStart) [ + pkgs.acl + pkgs.attr pkgs.bashInteractive # bash with ncurses support pkgs.bzip2 pkgs.coreutils @@ -197,6 +199,7 @@ rec { pkgs.gzip pkgs.iputils pkgs.less + pkgs.libcap pkgs.lvm2 pkgs.man pkgs.mdadm From 49bd768f99b4eab14a95df15821287051b73f2c3 Mon Sep 17 00:00:00 2001 From: Michael Raskin <7c6f434c@mail.ru> Date: Mon, 13 Apr 2009 09:35:03 +0000 Subject: [PATCH 3/3] As we do not really generate ejabbred.cfg, allow at least overwriting it manually svn path=/nixos/trunk/; revision=15006 --- etc/default.nix | 1 + etc/pam.d/ejabberd | 4 ++++ upstart-jobs/ejabberd.nix | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 etc/pam.d/ejabberd diff --git a/etc/default.nix b/etc/default.nix index 656e197eca5f..cf4085ba236d 100644 --- a/etc/default.nix +++ b/etc/default.nix @@ -259,6 +259,7 @@ import ../helpers/make-etc.nix { "kde" "cups" "ftp" + "ejabberd" "common" "common-console" # shared stuff for interactive local sessions ] diff --git a/etc/pam.d/ejabberd b/etc/pam.d/ejabberd new file mode 100644 index 000000000000..50f3cc5ce607 --- /dev/null +++ b/etc/pam.d/ejabberd @@ -0,0 +1,4 @@ +auth include common +account include common +password include common +session include common diff --git a/upstart-jobs/ejabberd.nix b/upstart-jobs/ejabberd.nix index d2a5084068f2..d7ab158af5d3 100644 --- a/upstart-jobs/ejabberd.nix +++ b/upstart-jobs/ejabberd.nix @@ -24,7 +24,7 @@ in fi mkdir -p ${cfg.confDir} - sed -e 's|{hosts, \["localhost"\]}.|{hosts, \[${cfg.virtualHosts}\]}.|' ${pkgs.ejabberd}/etc/ejabberd/ejabberd.cfg > ${cfg.confDir}/ejabberd.cfg + test -f ${cfg.confDir}/ejabberd.cfg || sed -e 's|{hosts, \["localhost"\]}.|{hosts, \[${cfg.virtualHosts}\]}.|' ${pkgs.ejabberd}/etc/ejabberd/ejabberd.cfg > ${cfg.confDir}/ejabberd.cfg end script respawn ${pkgs.bash}/bin/sh -c 'export PATH=$PATH:${pkgs.ejabberd}/sbin; cd ~; ejabberdctl --logs ${cfg.logsDir} --spool ${cfg.spoolDir} --config ${cfg.confDir}/ejabberd.cfg start; sleep 1d'