grafana-alloy: don't build the frontend twice
[NixPkgs.git] / nixos / modules / services / x11 / desktop-managers / pantheon.nix
blob1ab898d35bc2a2a68057389c7eabc4382c14935a
1 { config, lib, utils, pkgs, ... }:
3 with lib;
5 let
7   cfg = config.services.xserver.desktopManager.pantheon;
8   serviceCfg = config.services.pantheon;
10   nixos-gsettings-desktop-schemas = pkgs.pantheon.elementary-gsettings-schemas.override {
11     extraGSettingsOverridePackages = cfg.extraGSettingsOverridePackages;
12     extraGSettingsOverrides = cfg.extraGSettingsOverrides;
13   };
15   notExcluded = pkg: (!(lib.elem pkg config.environment.pantheon.excludePackages));
20   meta = {
21     doc = ./pantheon.md;
22     maintainers = teams.pantheon.members;
23   };
25   options = {
27     services.pantheon = {
29       contractor = {
30          enable = mkEnableOption "contractor, a desktop-wide extension service used by Pantheon";
31       };
33       apps.enable = mkEnableOption "Pantheon default applications";
35     };
37     services.xserver.desktopManager.pantheon = {
38       enable = mkOption {
39         type = types.bool;
40         default = false;
41         description = "Enable the pantheon desktop manager";
42       };
44       sessionPath = mkOption {
45         default = [];
46         type = types.listOf types.package;
47         example = literalExpression "[ pkgs.gpaste ]";
48         description = ''
49           Additional list of packages to be added to the session search path.
50           Useful for GSettings-conditional autostart.
52           Note that this should be a last resort; patching the package is preferred (see GPaste).
53         '';
54       };
56       extraWingpanelIndicators = mkOption {
57         default = null;
58         type = with types; nullOr (listOf package);
59         description = "Indicators to add to Wingpanel.";
60       };
62       extraSwitchboardPlugs = mkOption {
63         default = null;
64         type = with types; nullOr (listOf package);
65         description = "Plugs to add to Switchboard.";
66       };
68       extraGSettingsOverrides = mkOption {
69         default = "";
70         type = types.lines;
71         description = "Additional gsettings overrides.";
72       };
74       extraGSettingsOverridePackages = mkOption {
75         default = [];
76         type = types.listOf types.path;
77         description = "List of packages for which gsettings are overridden.";
78       };
80       debug = mkEnableOption "gnome-session debug messages";
82     };
84     environment.pantheon.excludePackages = mkOption {
85       default = [];
86       example = literalExpression "[ pkgs.pantheon.elementary-camera ]";
87       type = types.listOf types.package;
88       description = "Which packages pantheon should exclude from the default environment";
89     };
91   };
94   config = mkMerge [
95     (mkIf cfg.enable {
96       services.xserver.desktopManager.pantheon.sessionPath = utils.removePackagesByName [
97         pkgs.pantheon.pantheon-agent-geoclue2
98       ] config.environment.pantheon.excludePackages;
100       services.displayManager.sessionPackages = [ pkgs.pantheon.elementary-session-settings ];
102       # Ensure lightdm is used when Pantheon is enabled
103       # Without it screen locking will be nonfunctional because of the use of lightlocker
104       warnings = optional (config.services.xserver.displayManager.lightdm.enable != true)
105         ''
106           Using Pantheon without LightDM as a displayManager will break screenlocking from the UI.
107         '';
109       services.xserver.displayManager.lightdm.greeters.pantheon.enable = mkDefault true;
111       # Without this, elementary LightDM greeter will pre-select non-existent `default` session
112       # https://github.com/elementary/greeter/issues/368
113       services.displayManager.defaultSession = mkDefault "pantheon";
115       services.xserver.displayManager.sessionCommands = ''
116         if test "$XDG_CURRENT_DESKTOP" = "Pantheon"; then
117             true
118             ${concatMapStrings (p: ''
119               if [ -d "${p}/share/gsettings-schemas/${p.name}" ]; then
120                 export XDG_DATA_DIRS=$XDG_DATA_DIRS''${XDG_DATA_DIRS:+:}${p}/share/gsettings-schemas/${p.name}
121               fi
123               if [ -d "${p}/lib/girepository-1.0" ]; then
124                 export GI_TYPELIB_PATH=$GI_TYPELIB_PATH''${GI_TYPELIB_PATH:+:}${p}/lib/girepository-1.0
125                 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}${p}/lib
126               fi
127             '') cfg.sessionPath}
128         fi
129       '';
131       # Default services
132       hardware.bluetooth.enable = mkDefault true;
133       security.polkit.enable = true;
134       services.accounts-daemon.enable = true;
135       services.bamf.enable = true;
136       services.colord.enable = mkDefault true;
137       services.fwupd.enable = mkDefault true;
138       # TODO: Enable once #177946 is resolved
139       # services.packagekit.enable = mkDefault true;
140       services.power-profiles-daemon.enable = mkDefault true;
141       services.touchegg.enable = mkDefault true;
142       services.touchegg.package = pkgs.pantheon.touchegg;
143       services.tumbler.enable = mkDefault true;
144       services.system-config-printer.enable = (mkIf config.services.printing.enable (mkDefault true));
145       services.dbus.packages = with pkgs.pantheon; [
146         switchboard-plug-power
147         elementary-default-settings # accountsservice extensions
148       ];
149       services.pantheon.apps.enable = mkDefault true;
150       services.pantheon.contractor.enable = mkDefault true;
151       services.gnome.at-spi2-core.enable = true;
152       services.gnome.evolution-data-server.enable = true;
153       services.gnome.glib-networking.enable = true;
154       services.gnome.gnome-keyring.enable = true;
155       services.gvfs.enable = true;
156       services.gnome.rygel.enable = mkDefault true;
157       services.gsignond.enable = mkDefault true;
158       services.gsignond.plugins = with pkgs.gsignondPlugins; [ lastfm mail oauth ];
159       services.udisks2.enable = true;
160       services.upower.enable = config.powerManagement.enable;
161       services.libinput.enable = mkDefault true;
162       services.switcherooControl.enable = mkDefault true;
163       services.xserver.updateDbusEnvironment = true;
164       services.zeitgeist.enable = mkDefault true;
165       services.geoclue2.enable = mkDefault true;
166       # pantheon has pantheon-agent-geoclue2
167       services.geoclue2.enableDemoAgent = false;
168       services.geoclue2.appConfig."io.elementary.desktop.agent-geoclue2" = {
169         isAllowed = true;
170         isSystem = true;
171       };
172       services.udev.packages = [
173         pkgs.pantheon.gnome-settings-daemon
174         # Force enable KMS modifiers for devices that require them.
175         # https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1443
176         pkgs.pantheon.mutter
177       ];
178       services.orca.enable = mkDefault (notExcluded pkgs.orca);
179       systemd.packages = with pkgs; [
180         gnome-session
181         pantheon.gala
182         pantheon.gnome-settings-daemon
183         pantheon.elementary-session-settings
184       ];
185       programs.dconf.enable = true;
186       networking.networkmanager.enable = mkDefault true;
188       systemd.user.targets."gnome-session-x11-services".wants = [
189         "org.gnome.SettingsDaemon.XSettings.service"
190       ];
191       systemd.user.targets."gnome-session-x11-services-ready".wants = [
192         "org.gnome.SettingsDaemon.XSettings.service"
193       ];
195       # Global environment
196       environment.systemPackages = (with pkgs.pantheon; [
197         elementary-bluetooth-daemon
198         elementary-session-settings
199         elementary-settings-daemon
200         gala
201         gnome-settings-daemon
202         (switchboard-with-plugs.override {
203           plugs = cfg.extraSwitchboardPlugs;
204         })
205         (wingpanel-with-indicators.override {
206           indicators = cfg.extraWingpanelIndicators;
207         })
208       ]) ++ utils.removePackagesByName ((with pkgs; [
209         desktop-file-utils
210         glib # for gsettings program
211         gnome-menus
212         adwaita-icon-theme
213         gtk3.out # for gtk-launch program
214         onboard
215         sound-theme-freedesktop
216         xdg-user-dirs # Update user dirs as described in https://freedesktop.org/wiki/Software/xdg-user-dirs/
217       ]) ++ (with pkgs.pantheon; [
218         # Artwork
219         elementary-gtk-theme
220         elementary-icon-theme
221         elementary-sound-theme
222         elementary-wallpapers
224         # Desktop
225         elementary-default-settings
226         elementary-dock
227         elementary-shortcut-overlay
229         # Services
230         elementary-capnet-assist
231         elementary-notifications
232         pantheon-agent-geoclue2
233         pantheon-agent-polkit
234       ])) config.environment.pantheon.excludePackages;
236       # Settings from elementary-default-settings
237       environment.etc."gtk-3.0/settings.ini".source = "${pkgs.pantheon.elementary-default-settings}/etc/gtk-3.0/settings.ini";
239       xdg.mime.enable = true;
240       xdg.icons.enable = true;
242       xdg.portal.enable = true;
243       xdg.portal.extraPortals = [
244         pkgs.xdg-desktop-portal-gtk
245       ] ++ (with pkgs.pantheon; [
246         elementary-files
247         elementary-settings-daemon
248         xdg-desktop-portal-pantheon
249       ]);
251       xdg.portal.configPackages = mkDefault [ pkgs.pantheon.elementary-default-settings ];
253       # Override GSettings schemas
254       environment.sessionVariables.NIX_GSETTINGS_OVERRIDES_DIR = "${nixos-gsettings-desktop-schemas}/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas";
256       environment.sessionVariables.GNOME_SESSION_DEBUG = mkIf cfg.debug "1";
258       environment.pathsToLink = [
259         # FIXME: modules should link subdirs of `/share` rather than relying on this
260         "/share"
261       ];
263       # Otherwise you can't store NetworkManager Secrets with
264       # "Store the password only for this user"
265       programs.nm-applet.enable = true;
266       # Pantheon has its own network indicator
267       programs.nm-applet.indicator = false;
269       # Shell integration for VTE terminals
270       programs.bash.vteIntegration = mkDefault true;
271       programs.zsh.vteIntegration = mkDefault true;
273       # Default Fonts
274       fonts.packages = with pkgs; [
275         inter
276         open-dyslexic
277         open-sans
278         roboto-mono
279       ];
281       fonts.fontconfig.defaultFonts = {
282         monospace = [ "Roboto Mono" ];
283         sansSerif = [ "Inter" ];
284       };
285     })
287     (mkIf serviceCfg.apps.enable {
288       programs.evince.enable = mkDefault (notExcluded pkgs.evince);
289       programs.file-roller.enable = mkDefault (notExcluded pkgs.file-roller);
291       environment.systemPackages = utils.removePackagesByName ([
292         pkgs.gnome-font-viewer
293       ] ++ (with pkgs.pantheon; [
294         elementary-calculator
295         elementary-calendar
296         elementary-camera
297         elementary-code
298         elementary-files
299         elementary-mail
300         elementary-music
301         elementary-photos
302         elementary-screenshot
303         elementary-tasks
304         elementary-terminal
305         elementary-videos
306         epiphany
307       ] ++ lib.optionals config.services.flatpak.enable [
308         # Only install appcenter if flatpak is enabled before
309         # https://github.com/NixOS/nixpkgs/issues/15932 is resolved.
310         appcenter
311         sideload
312       ])) config.environment.pantheon.excludePackages;
314       # needed by screenshot
315       fonts.packages = [
316         pkgs.pantheon.elementary-redacted-script
317       ];
318     })
320     (mkIf serviceCfg.contractor.enable {
321       environment.systemPackages = with pkgs.pantheon; [
322         contractor
323         file-roller-contract
324       ];
326       environment.pathsToLink = [
327         "/share/contractor"
328       ];
329     })
331   ];