summary refs log tree commit diff
path: root/nixos/modules/services/x11/desktop-managers/kde5.nix
blob: 06fc622325f7686309add4159a457ac1b1dcf765 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
{ config, lib, pkgs, ... }:

with lib;

let

  xcfg = config.services.xserver;
  cfg = xcfg.desktopManager.kde5;
  xorg = pkgs.xorg;

  kf5 = pkgs.kf5_stable;
  plasma5 = pkgs.plasma5_stable;
  kdeApps = pkgs.kdeApps_stable;

in

{
  options = {

    services.xserver.desktopManager.kde5 = {
      enable = mkOption {
        type = types.bool;
        default = false;
        description = "Enable the Plasma 5 (KDE 5) desktop environment.";
      };

      phonon = {

        gstreamer = {
          enable = mkOption {
            type = types.bool;
            default = true;
            description = "Enable the GStreamer Phonon backend (recommended).";
          };
        };

        vlc = {
          enable = mkOption {
            type = types.bool;
            default = false;
            description = "Enable the VLC Phonon backend.";
          };
        };

      };

    };

  };


  config = mkIf (xcfg.enable && cfg.enable) {

    warnings = optional config.services.xserver.desktopManager.kde4.enable
      "KDE 4 should not be enabled at the same time as KDE 5";

    services.xserver.desktopManager.session = singleton {
      name = "kde5";
      bgSupport = true;
      start = ''exec ${plasma5.plasma-workspace}/bin/startkde;'';
    };

    security.setuidOwners = singleton {
      program = "kcheckpass";
      source = "${plasma5.plasma-workspace}/lib/libexec/kcheckpass";
      owner = "root";
      group = "root";
      setuid = true;
    };

    environment.systemPackages =
      [
        pkgs.qt4 # qtconfig is the only way to set Qt 4 theme

        kf5.frameworkintegration
        kf5.kinit

        plasma5.breeze
        plasma5.kde-cli-tools
        plasma5.kdeplasma-addons
        plasma5.kgamma5
        plasma5.khelpcenter
        plasma5.khotkeys
        plasma5.kinfocenter
        plasma5.kmenuedit
        plasma5.kscreen
        plasma5.ksysguard
        plasma5.kwayland
        plasma5.kwin
        plasma5.kwrited
        plasma5.milou
        plasma5.oxygen
        plasma5.polkit-kde-agent
        plasma5.systemsettings

        plasma5.plasma-desktop
        plasma5.plasma-workspace
        plasma5.plasma-workspace-wallpapers

        kdeApps.ark
        kdeApps.dolphin
        kdeApps.dolphin-plugins
        kdeApps.ffmpegthumbs
        kdeApps.gwenview
        kdeApps.kate
        kdeApps.kdegraphics-thumbnailers
        kdeApps.konsole
        kdeApps.okular
        kdeApps.print-manager

        # Oxygen icons moved to KDE Frameworks 5.16 and later.
        (kdeApps.oxygen-icons or kf5.oxygen-icons5)
        pkgs.hicolor_icon_theme

        plasma5.kde-gtk-config
      ]

      # Plasma 5.5 and later has a Breeze GTK theme.
      # If it is not available, Orion is very similar to Breeze.
      ++ lib.optional (!(lib.hasAttr "breeze-gtk" plasma5)) pkgs.orion

      # Install Breeze icons if available
      ++ lib.optional (lib.hasAttr "breeze-icons" kf5) kf5.breeze-icons

      # Optional hardware support features
      ++ lib.optional config.hardware.bluetooth.enable plasma5.bluedevil
      ++ lib.optional config.networking.networkmanager.enable plasma5.plasma-nm
      ++ lib.optional config.hardware.pulseaudio.enable plasma5.plasma-pa
      ++ lib.optional config.powerManagement.enable plasma5.powerdevil

      ++ lib.optionals cfg.phonon.gstreamer.enable
        [
          pkgs.phonon_backend_gstreamer
          pkgs.gst_all.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.phonon_qt5_backend_gstreamer
          pkgs.gst_all_1.gstreamer
          pkgs.gst_all_1.gst-plugins-base
          pkgs.gst_all_1.gst-plugins-good
          pkgs.gst_all_1.gst-plugins-ugly
          pkgs.gst_all_1.gst-plugins-bad
          pkgs.gst_all_1.gst-libav # for mp3 playback
        ]

      ++ lib.optionals cfg.phonon.vlc.enable
        [
          pkgs.phonon_qt5_backend_vlc
          pkgs.phonon_backend_vlc
        ];

    environment.pathsToLink = [ "/share" ];

    environment.etc = singleton {
      source = "${pkgs.xkeyboard_config}/etc/X11/xkb";
      target = "X11/xkb";
    };

    environment.profileRelativeEnvVars =
      mkIf cfg.phonon.gstreamer.enable
      {
        GST_PLUGIN_SYSTEM_PATH = [ "/lib/gstreamer-0.10" ];
        GST_PLUGIN_SYSTEM_PATH_1_0 = [ "/lib/gstreamer-1.0" ];
      };

    # Enable GTK applications to load SVG icons
    environment.variables = mkIf (lib.hasAttr "breeze-icons" kf5) {
      GDK_PIXBUF_MODULE_FILE = "${pkgs.librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache";
    };

    fonts.fonts = [ (plasma5.oxygen-fonts or pkgs.noto-fonts) ];

    programs.ssh.askPassword = "${plasma5.ksshaskpass}/bin/ksshaskpass";

    # Enable helpful DBus services.
    services.udisks2.enable = true;
    services.upower.enable = config.powerManagement.enable;

    # Extra UDEV rules used by Solid
    services.udev.packages = [ pkgs.media-player-info ];

    services.xserver.displayManager.sddm = {
      theme = "breeze";
      themes = [
        plasma5.plasma-workspace
        (kdeApps.oxygen-icons or kf5.oxygen-icons5)
      ];
    };

    security.pam.services.kde = { allowNullPassword = true; };

  };

}