summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorambrop7@gmail.com <Ambroz Bizjak>2014-09-24 23:23:50 +0200
committerambrop7@gmail.com <Ambroz Bizjak>2014-09-24 23:50:23 +0200
commitbea503ec3665a2b38ff364b61f179c38918915be (patch)
tree609f779d8f71fc39aeab961e78197809abc71a8b /nixos
parent0e8e45f3ab3cfd4b57d8ee52b8b88bf3412242c0 (diff)
downloadnixlib-bea503ec3665a2b38ff364b61f179c38918915be.tar
nixlib-bea503ec3665a2b38ff364b61f179c38918915be.tar.gz
nixlib-bea503ec3665a2b38ff364b61f179c38918915be.tar.bz2
nixlib-bea503ec3665a2b38ff364b61f179c38918915be.tar.lz
nixlib-bea503ec3665a2b38ff364b61f179c38918915be.tar.xz
nixlib-bea503ec3665a2b38ff364b61f179c38918915be.tar.zst
nixlib-bea503ec3665a2b38ff364b61f179c38918915be.zip
kde: Allow kde_next as a desktop environment
This is the same as
https://github.com/wmertens/nixpkgs/commit/93fda9e353bb9408ea80339f36fa513742d65ddf
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/x11/desktop-managers/default.nix2
-rw-r--r--nixos/modules/services/x11/desktop-managers/kde4_next.nix163
2 files changed, 164 insertions, 1 deletions
diff --git a/nixos/modules/services/x11/desktop-managers/default.nix b/nixos/modules/services/x11/desktop-managers/default.nix
index ebdb2ad06491..43e04a3076c6 100644
--- a/nixos/modules/services/x11/desktop-managers/default.nix
+++ b/nixos/modules/services/x11/desktop-managers/default.nix
@@ -18,7 +18,7 @@ in
   # determines the default: later modules (if enabled) are preferred.
   # E.g., if KDE is enabled, it supersedes xterm.
   imports = [
-    ./none.nix ./xterm.nix ./xfce.nix ./kde4.nix
+    ./none.nix ./xterm.nix ./xfce.nix ./kde4.nix ./kde4_next.nix
     ./e17.nix ./e18.nix ./e19.nix ./gnome3.nix ./xbmc.nix
   ];
 
diff --git a/nixos/modules/services/x11/desktop-managers/kde4_next.nix b/nixos/modules/services/x11/desktop-managers/kde4_next.nix
new file mode 100644
index 000000000000..568094358ba0
--- /dev/null
+++ b/nixos/modules/services/x11/desktop-managers/kde4_next.nix
@@ -0,0 +1,163 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+  xcfg = config.services.xserver;
+  cfg = xcfg.desktopManager.kde4_next;
+  xorg = pkgs.xorg;
+  kde = pkgs.kde4_next;
+
+  # Disable Nepomuk and Strigi by default.  As of KDE 4.7, they don't
+  # really work very well (e.g. searching files often fails to find
+  # files), segfault sometimes and consume significant resources.
+  # They can be re-enabled in the KDE System Settings under "Desktop
+  # Search".
+  nepomukConfig = pkgs.writeTextFile
+    { name = "nepomuk-config";
+      destination = "/share/config/nepomukserverrc";
+      text =
+        ''
+          [Basic Settings]
+          Start Nepomuk=false
+
+          [Service-nepomukstrigiservice]
+          autostart=false
+        '';
+    };
+
+  phononBackends = {
+    gstreamer = [
+      pkgs.phonon_backend_gstreamer
+      pkgs.gst_all.gstPluginsBase
+      pkgs.gst_all.gstPluginsGood
+      pkgs.gst_all.gstPluginsUgly
+      pkgs.gst_all.gstPluginsBad
+      pkgs.gst_all.gstFfmpeg # for mp3 playback
+      pkgs.gst_all.gstreamer # needed?
+    ];
+
+    vlc = [pkgs.phonon_backend_vlc];
+  };
+
+  phononBackendPackages = flip concatMap cfg.phononBackends
+    (name: attrByPath [name] (throw "unknown phonon backend `${name}'") phononBackends);
+
+in
+
+{
+  options = {
+
+    services.xserver.desktopManager.kde4_next = {
+      enable = mkOption {
+        type = types.bool;
+        default = false;
+        description = "Enable the KDE 4 desktop environment.";
+      };
+
+      phononBackends = mkOption {
+        type = types.listOf types.str;
+        default = ["gstreamer"];
+        example = ["gstreamer" "vlc"];
+        description = "Which phonon multimedia backend kde should use";
+      };
+    };
+
+  };
+
+
+  config = mkIf (xcfg.enable && cfg.enable) {
+
+    # If KDE 4 is enabled, make it the default desktop manager (unless
+    # overridden by the user's configuration).
+    # !!! doesn't work yet ("Multiple definitions. Only one is allowed
+    # for this option.")
+    # services.xserver.desktopManager.default = mkOverride 900 "kde4";
+
+    services.xserver.desktopManager.session = singleton
+      { name = "kde4_next";
+        bgSupport = true;
+        start =
+          ''
+            # The KDE icon cache is supposed to update itself
+            # automatically, but it uses the timestamp on the icon
+            # theme directory as a trigger.  Since in Nix the
+            # timestamp is always the same, this doesn't work.  So as
+            # a workaround, nuke the icon cache on login.  This isn't
+            # perfect, since it may require logging out after
+            # installing new applications to update the cache.
+            # See http://lists-archives.org/kde-devel/26175-what-when-will-icon-cache-refresh.html
+            rm -fv $HOME/.kde/cache-*/icon-cache.kcache
+
+            # Qt writes a weird ‘libraryPath’ line to
+            # ~/.config/Trolltech.conf that causes the KDE plugin
+            # paths of previous KDE invocations to be searched.
+            # Obviously using mismatching KDE libraries is potentially
+            # disastrous, so here we nuke references to the Nix store
+            # in Trolltech.conf.  A better solution would be to stop
+            # Qt from doing this wackiness in the first place.
+            if [ -e $HOME/.config/Trolltech.conf ]; then
+                sed -e '/nix\\store\|nix\/store/ d' -i $HOME/.config/Trolltech.conf
+            fi
+
+            # Start KDE.
+            exec ${kde.kdebase_workspace}/bin/startkde
+          '';
+      };
+
+    security.setuidOwners = singleton
+      { program = "kcheckpass";
+        source = "${kde.kdebase_workspace}/lib/kde4/libexec/kcheckpass";
+        owner = "root";
+        group = "root";
+        setuid = true;
+      };
+
+    environment.systemPackages =
+        [ kde.kdelibs
+
+          kde.kde_baseapps # Splitted kdebase
+          kde.kde_workspace
+          kde.kde_runtime
+          kde.konsole
+          kde.kate
+
+          kde.kde_wallpapers # contains kdm's default background
+          kde.oxygen_icons
+          pkgs.virtuoso # to enable Nepomuk to find Virtuoso
+
+          # Starts KDE's Polkit authentication agent.
+          kde.polkit_kde_agent
+
+          # Miscellaneous runtime dependencies.
+          kde.qt4 # needed for qdbus
+          pkgs.shared_mime_info
+          xorg.xmessage # so that startkde can show error messages
+          xorg.xset # used by startkde, non-essential
+          xorg.xauth # used by kdesu
+          pkgs.shared_desktop_ontologies # used by nepomuk
+          pkgs.strigi # used by nepomuk
+          pkgs.mysql # used by akonadi
+        ]
+      ++ lib.optional config.hardware.pulseaudio.enable kde.kmix  # Perhaps this should always be enabled
+      ++ lib.optional config.hardware.bluetooth.enable kde.bluedevil
+      ++ lib.optional config.networking.networkmanager.enable kde.networkmanagement
+      ++ [ nepomukConfig ] ++ phononBackendPackages;
+
+    environment.pathsToLink = [ "/share" ];
+
+    environment.etc = singleton
+      { source = "${pkgs.xkeyboard_config}/etc/X11/xkb";
+        target = "X11/xkb";
+      };
+
+    # Enable helpful DBus services.
+    services.udisks2.enable = true;
+    services.upower.enable = config.powerManagement.enable;
+
+    security.pam.services.kde = { allowNullPassword = true; };
+
+  };
+
+}