at v192 5.8 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 7 xcfg = config.services.xserver; 8 cfg = xcfg.desktopManager.kde4; 9 xorg = pkgs.xorg; 10 kde_workspace = config.services.xserver.desktopManager.kde4.kdeWorkspacePackage; 11 12 # Disable Nepomuk and Strigi by default. As of KDE 4.7, they don't 13 # really work very well (e.g. searching files often fails to find 14 # files), segfault sometimes and consume significant resources. 15 # They can be re-enabled in the KDE System Settings under "Desktop 16 # Search". 17 nepomukConfig = pkgs.writeTextFile 18 { name = "nepomuk-config"; 19 destination = "/share/config/nepomukserverrc"; 20 text = 21 '' 22 [Basic Settings] 23 Start Nepomuk=false 24 25 [Service-nepomukstrigiservice] 26 autostart=false 27 ''; 28 }; 29 30 phononBackends = { 31 gstreamer = [ 32 pkgs.phonon_backend_gstreamer 33 pkgs.gst_all.gstPluginsBase 34 pkgs.gst_all.gstPluginsGood 35 pkgs.gst_all.gstPluginsUgly 36 pkgs.gst_all.gstPluginsBad 37 pkgs.gst_all.gstFfmpeg # for mp3 playback 38 pkgs.gst_all.gstreamer # needed? 39 ]; 40 41 vlc = [pkgs.phonon_backend_vlc]; 42 }; 43 44 phononBackendPackages = flip concatMap cfg.phononBackends 45 (name: attrByPath [name] (throw "unknown phonon backend `${name}'") phononBackends); 46 47in 48 49{ 50 options = { 51 52 services.xserver.desktopManager.kde4 = { 53 enable = mkOption { 54 type = types.bool; 55 default = false; 56 description = "Enable the KDE 4 desktop environment."; 57 }; 58 59 phononBackends = mkOption { 60 type = types.listOf types.str; 61 default = ["gstreamer"]; 62 example = ["gstreamer" "vlc"]; 63 description = "Which phonon multimedia backend kde should use"; 64 }; 65 66 kdeWorkspacePackage = mkOption { 67 internal = true; 68 default = pkgs.kde4.kde_workspace; 69 type = types.package; 70 description = "Custom kde-workspace, used for NixOS rebranding."; 71 }; 72 }; 73 }; 74 75 76 config = mkIf (xcfg.enable && cfg.enable) { 77 78 # If KDE 4 is enabled, make it the default desktop manager (unless 79 # overridden by the user's configuration). 80 # !!! doesn't work yet ("Multiple definitions. Only one is allowed 81 # for this option.") 82 # services.xserver.desktopManager.default = mkOverride 900 "kde4"; 83 84 services.xserver.desktopManager.session = singleton 85 { name = "kde4"; 86 bgSupport = true; 87 start = 88 '' 89 # The KDE icon cache is supposed to update itself 90 # automatically, but it uses the timestamp on the icon 91 # theme directory as a trigger. Since in Nix the 92 # timestamp is always the same, this doesn't work. So as 93 # a workaround, nuke the icon cache on login. This isn't 94 # perfect, since it may require logging out after 95 # installing new applications to update the cache. 96 # See http://lists-archives.org/kde-devel/26175-what-when-will-icon-cache-refresh.html 97 rm -fv $HOME/.kde/cache-*/icon-cache.kcache 98 99 # Qt writes a weird libraryPath line to 100 # ~/.config/Trolltech.conf that causes the KDE plugin 101 # paths of previous KDE invocations to be searched. 102 # Obviously using mismatching KDE libraries is potentially 103 # disastrous, so here we nuke references to the Nix store 104 # in Trolltech.conf. A better solution would be to stop 105 # Qt from doing this wackiness in the first place. 106 if [ -e $HOME/.config/Trolltech.conf ]; then 107 sed -e '/nix\\store\|nix\/store/ d' -i $HOME/.config/Trolltech.conf 108 fi 109 110 # Start KDE. 111 exec ${kde_workspace}/bin/startkde 112 ''; 113 }; 114 115 security.setuidOwners = singleton 116 { program = "kcheckpass"; 117 source = "${kde_workspace}/lib/kde4/libexec/kcheckpass"; 118 owner = "root"; 119 group = "root"; 120 setuid = true; 121 }; 122 123 environment.systemPackages = 124 [ pkgs.kde4.kdelibs 125 126 pkgs.kde4.kde_baseapps # Splitted kdebase 127 kde_workspace 128 pkgs.kde4.kde_runtime 129 pkgs.kde4.konsole 130 pkgs.kde4.kate 131 132 pkgs.kde4.kde_wallpapers # contains kdm's default background 133 pkgs.kde4.oxygen_icons 134 pkgs.virtuoso # to enable Nepomuk to find Virtuoso 135 136 # Starts KDE's Polkit authentication agent. 137 pkgs.kde4.polkit_kde_agent 138 139 # Miscellaneous runtime dependencies. 140 pkgs.kde4.qt4 # needed for qdbus 141 pkgs.shared_mime_info 142 xorg.xmessage # so that startkde can show error messages 143 xorg.xset # used by startkde, non-essential 144 xorg.xauth # used by kdesu 145 pkgs.shared_desktop_ontologies # used by nepomuk 146 pkgs.strigi # used by nepomuk 147 pkgs.kde4.akonadi 148 pkgs.mysql # used by akonadi 149 pkgs.kde4.kdepim_runtime 150 ] 151 ++ lib.optional config.hardware.pulseaudio.enable pkgs.kde4.kmix # Perhaps this should always be enabled 152 ++ lib.optional config.hardware.bluetooth.enable pkgs.kde4.bluedevil 153 ++ lib.optional config.networking.networkmanager.enable pkgs.kde4.plasma-nm 154 ++ [ nepomukConfig ] ++ phononBackendPackages; 155 156 environment.pathsToLink = [ "/share" ]; 157 158 environment.profileRelativeEnvVars = mkIf (lib.elem "gstreamer" cfg.phononBackends) { 159 GST_PLUGIN_SYSTEM_PATH = [ "/lib/gstreamer-0.10" ]; 160 }; 161 162 environment.etc = singleton 163 { source = "${pkgs.xkeyboard_config}/etc/X11/xkb"; 164 target = "X11/xkb"; 165 }; 166 167 # Enable helpful DBus services. 168 services.udisks2.enable = true; 169 services.upower.enable = config.powerManagement.enable; 170 171 security.pam.services.kde = { allowNullPassword = true; }; 172 173 }; 174 175}