1 { config, lib, pkgs, utils, ... }:
7 cfg = config.services.xserver.desktopManager.gnome;
8 serviceCfg = config.services.gnome;
10 # Prioritize nautilus by default when opening directories
11 mimeAppsList = pkgs.writeTextFile {
12 name = "gnome-mimeapps";
13 destination = "/share/applications/mimeapps.list";
15 [Default Applications]
16 inode/directory=nautilus.desktop;org.gnome.Nautilus.desktop
20 defaultFavoriteAppsOverride = ''
22 favorite-apps=[ 'org.gnome.Epiphany.desktop', 'org.gnome.Geary.desktop', 'org.gnome.Calendar.desktop', 'org.gnome.Music.desktop', 'org.gnome.Nautilus.desktop' ]
25 nixos-background-light = pkgs.nixos-artwork.wallpapers.simple-blue;
26 nixos-background-dark = pkgs.nixos-artwork.wallpapers.simple-dark-gray;
28 # TODO: Having https://github.com/NixOS/nixpkgs/issues/54150 would supersede this
29 nixos-gsettings-desktop-schemas = pkgs.gnome.nixos-gsettings-overrides.override {
30 inherit (cfg) extraGSettingsOverrides extraGSettingsOverridePackages favoriteAppsOverride;
31 inherit flashbackEnabled nixos-background-dark nixos-background-light;
34 nixos-background-info = pkgs.writeTextFile rec {
35 name = "nixos-background-info";
38 <!DOCTYPE wallpapers SYSTEM "gnome-wp-list.dtd">
40 <wallpaper deleted="false">
42 <filename>${nixos-background-light.gnomeFilePath}</filename>
43 <filename-dark>${nixos-background-dark.gnomeFilePath}</filename-dark>
44 <options>zoom</options>
45 <shade_type>solid</shade_type>
46 <pcolor>#3a4ba0</pcolor>
47 <scolor>#2f302f</scolor>
51 destination = "/share/gnome-background-properties/nixos.xml";
54 flashbackEnabled = cfg.flashback.enableMetacity || length cfg.flashback.customSessions > 0;
55 flashbackWms = optional cfg.flashback.enableMetacity {
58 wmCommand = "${pkgs.gnome.metacity}/bin/metacity";
59 enableGnomePanel = true;
60 } ++ cfg.flashback.customSessions;
62 notExcluded = pkg: mkDefault (!(lib.elem pkg config.environment.gnome.excludePackages));
70 maintainers = teams.gnome.members;
75 (mkRenamedOptionModule
76 [ "services" "gnome3" "core-os-services" "enable" ]
77 [ "services" "gnome" "core-os-services" "enable" ]
79 (mkRenamedOptionModule
80 [ "services" "gnome3" "core-shell" "enable" ]
81 [ "services" "gnome" "core-shell" "enable" ]
83 (mkRenamedOptionModule
84 [ "services" "gnome3" "core-utilities" "enable" ]
85 [ "services" "gnome" "core-utilities" "enable" ]
87 (mkRenamedOptionModule
88 [ "services" "gnome3" "core-developer-tools" "enable" ]
89 [ "services" "gnome" "core-developer-tools" "enable" ]
91 (mkRenamedOptionModule
92 [ "services" "gnome3" "games" "enable" ]
93 [ "services" "gnome" "games" "enable" ]
95 (mkRenamedOptionModule
96 [ "services" "gnome3" "experimental-features" "realtime-scheduling" ]
97 [ "services" "gnome" "experimental-features" "realtime-scheduling" ]
99 (mkRenamedOptionModule
100 [ "services" "xserver" "desktopManager" "gnome3" "enable" ]
101 [ "services" "xserver" "desktopManager" "gnome" "enable" ]
103 (mkRenamedOptionModule
104 [ "services" "xserver" "desktopManager" "gnome3" "sessionPath" ]
105 [ "services" "xserver" "desktopManager" "gnome" "sessionPath" ]
107 (mkRenamedOptionModule
108 [ "services" "xserver" "desktopManager" "gnome3" "favoriteAppsOverride" ]
109 [ "services" "xserver" "desktopManager" "gnome" "favoriteAppsOverride" ]
111 (mkRenamedOptionModule
112 [ "services" "xserver" "desktopManager" "gnome3" "extraGSettingsOverrides" ]
113 [ "services" "xserver" "desktopManager" "gnome" "extraGSettingsOverrides" ]
115 (mkRenamedOptionModule
116 [ "services" "xserver" "desktopManager" "gnome3" "extraGSettingsOverridePackages" ]
117 [ "services" "xserver" "desktopManager" "gnome" "extraGSettingsOverridePackages" ]
119 (mkRenamedOptionModule
120 [ "services" "xserver" "desktopManager" "gnome3" "debug" ]
121 [ "services" "xserver" "desktopManager" "gnome" "debug" ]
123 (mkRenamedOptionModule
124 [ "services" "xserver" "desktopManager" "gnome3" "flashback" ]
125 [ "services" "xserver" "desktopManager" "gnome" "flashback" ]
127 (mkRenamedOptionModule
128 [ "environment" "gnome3" "excludePackages" ]
129 [ "environment" "gnome" "excludePackages" ]
131 (mkRemovedOptionModule
132 [ "services" "gnome" "experimental-features" "realtime-scheduling" ]
133 "Set `security.rtkit.enable = true;` to make realtime scheduling possible. (Still needs to be enabled using GSettings.)"
140 core-os-services.enable = mkEnableOption (lib.mdDoc "essential services for GNOME3");
141 core-shell.enable = mkEnableOption (lib.mdDoc "GNOME Shell services");
142 core-utilities.enable = mkEnableOption (lib.mdDoc "GNOME core utilities");
143 core-developer-tools.enable = mkEnableOption (lib.mdDoc "GNOME core developer tools");
144 games.enable = mkEnableOption (lib.mdDoc "GNOME games");
147 services.xserver.desktopManager.gnome = {
151 description = lib.mdDoc "Enable GNOME desktop manager.";
154 sessionPath = mkOption {
156 type = types.listOf types.package;
157 example = literalExpression "[ pkgs.gnome.gpaste ]";
158 description = lib.mdDoc ''
159 Additional list of packages to be added to the session search path.
160 Useful for GNOME Shell extensions or GSettings-conditional autostart.
162 Note that this should be a last resort; patching the package is preferred (see GPaste).
166 favoriteAppsOverride = mkOption {
167 internal = true; # this is messy
168 default = defaultFavoriteAppsOverride;
170 example = literalExpression ''
173 favorite-apps=[ 'firefox.desktop', 'org.gnome.Calendar.desktop' ]
176 description = lib.mdDoc "List of desktop files to put as favorite apps into gnome-shell. These need to be installed somehow globally.";
179 extraGSettingsOverrides = mkOption {
182 description = lib.mdDoc "Additional gsettings overrides.";
185 extraGSettingsOverridePackages = mkOption {
187 type = types.listOf types.path;
188 description = lib.mdDoc "List of packages for which gsettings are overridden.";
191 debug = mkEnableOption (lib.mdDoc "gnome-session debug messages");
194 enableMetacity = mkEnableOption (lib.mdDoc "the standard GNOME Flashback session with Metacity");
196 customSessions = mkOption {
197 type = types.listOf (types.submodule {
200 type = types.strMatching "[a-zA-Z0-9_-]+";
201 description = lib.mdDoc "A unique identifier for the window manager.";
207 description = lib.mdDoc "The name of the window manager to show in the session chooser.";
211 wmCommand = mkOption {
213 description = lib.mdDoc "The executable of the window manager to use.";
214 example = literalExpression ''"''${pkgs.haskellPackages.xmonad}/bin/xmonad"'';
217 enableGnomePanel = mkOption {
221 description = lib.mdDoc "Whether to enable the GNOME panel in this session.";
226 description = lib.mdDoc "Other GNOME Flashback sessions to enable.";
229 panelModulePackages = mkOption {
230 default = [ pkgs.gnome.gnome-applets ];
231 defaultText = literalExpression "[ pkgs.gnome.gnome-applets ]";
232 type = types.listOf types.package;
233 description = lib.mdDoc ''
234 Packages containing modules that should be made available to `gnome-panel` (usually for applets).
236 If you're packaging something to use here, please install the modules in `$out/lib/gnome-panel/modules`.
242 environment.gnome.excludePackages = mkOption {
244 example = literalExpression "[ pkgs.gnome.totem ]";
245 type = types.listOf types.package;
246 description = lib.mdDoc "Which packages gnome should exclude from the default environment";
252 (mkIf (cfg.enable || flashbackEnabled) {
253 # Seed our configuration into nixos-generate-config
254 system.nixos-generate-config.desktopConfiguration = [''
255 # Enable the GNOME Desktop Environment.
256 services.xserver.displayManager.gdm.enable = true;
257 services.xserver.desktopManager.gnome.enable = true;
260 services.gnome.core-os-services.enable = true;
261 services.gnome.core-shell.enable = true;
262 services.gnome.core-utilities.enable = mkDefault true;
264 services.xserver.displayManager.sessionPackages = [ pkgs.gnome.gnome-session.sessions ];
266 environment.extraInit = ''
267 ${concatMapStrings (p: ''
268 if [ -d "${p}/share/gsettings-schemas/${p.name}" ]; then
269 export XDG_DATA_DIRS=$XDG_DATA_DIRS''${XDG_DATA_DIRS:+:}${p}/share/gsettings-schemas/${p.name}
272 if [ -d "${p}/lib/girepository-1.0" ]; then
273 export GI_TYPELIB_PATH=$GI_TYPELIB_PATH''${GI_TYPELIB_PATH:+:}${p}/lib/girepository-1.0
274 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}${p}/lib
279 environment.systemPackages = cfg.sessionPath;
281 environment.sessionVariables.GNOME_SESSION_DEBUG = mkIf cfg.debug "1";
283 # Override GSettings schemas
284 environment.sessionVariables.NIX_GSETTINGS_OVERRIDES_DIR = "${nixos-gsettings-desktop-schemas}/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas";
287 (mkIf flashbackEnabled {
288 services.xserver.displayManager.sessionPackages =
290 wmNames = map (wm: wm.wmName) flashbackWms;
291 namesAreUnique = lib.unique wmNames == wmNames;
293 assert (assertMsg namesAreUnique "Flashback WM names must be unique.");
296 pkgs.gnome.gnome-flashback.mkSessionForWm {
297 inherit (wm) wmName wmLabel wmCommand;
301 security.pam.services.gnome-flashback = {
302 enableGnomeKeyring = true;
305 systemd.packages = with pkgs.gnome; [
307 ] ++ map gnome-flashback.mkSystemdTargetForWm flashbackWms;
309 environment.systemPackages = with pkgs.gnome; [
311 (gnome-panel-with-modules.override {
312 panelModulePackages = cfg.flashback.panelModulePackages;
315 # For /share/applications/${wmName}.desktop
316 ++ (map (wm: gnome-flashback.mkWmApplication { inherit (wm) wmName wmLabel wmCommand; }) flashbackWms)
317 # For /share/gnome-session/sessions/gnome-flashback-${wmName}.session
318 ++ (map (wm: gnome-flashback.mkGnomeSession { inherit (wm) wmName wmLabel enableGnomePanel; }) flashbackWms);
321 (mkIf serviceCfg.core-os-services.enable {
322 hardware.bluetooth.enable = mkDefault true;
323 hardware.pulseaudio.enable = mkDefault true;
324 programs.dconf.enable = true;
325 security.polkit.enable = true;
326 services.accounts-daemon.enable = true;
327 services.dleyna-renderer.enable = mkDefault true;
328 services.dleyna-server.enable = mkDefault true;
329 services.power-profiles-daemon.enable = mkDefault true;
330 services.gnome.at-spi2-core.enable = true;
331 services.gnome.evolution-data-server.enable = true;
332 services.gnome.gnome-keyring.enable = true;
333 services.gnome.gnome-online-accounts.enable = mkDefault true;
334 services.gnome.gnome-online-miners.enable = true;
335 services.gnome.tracker-miners.enable = mkDefault true;
336 services.gnome.tracker.enable = mkDefault true;
337 services.hardware.bolt.enable = mkDefault true;
338 # TODO: Enable once #177946 is resolved
339 # services.packagekit.enable = mkDefault true;
340 services.udisks2.enable = true;
341 services.upower.enable = config.powerManagement.enable;
342 services.xserver.libinput.enable = mkDefault true; # for controlling touchpad settings via gnome control center
344 # Explicitly enabled since GNOME will be severely broken without these.
345 xdg.mime.enable = true;
346 xdg.icons.enable = true;
348 xdg.portal.enable = true;
349 xdg.portal.extraPortals = [
350 pkgs.xdg-desktop-portal-gnome
351 (pkgs.xdg-desktop-portal-gtk.override {
352 # Do not build portals that we already have.
353 buildPortalsInGnome = false;
356 xdg.portal.configPackages = mkDefault [ pkgs.gnome.gnome-session ];
358 networking.networkmanager.enable = mkDefault true;
360 services.xserver.updateDbusEnvironment = true;
362 # gnome has a custom alert theme but it still
363 # inherits from the freedesktop theme.
364 environment.systemPackages = with pkgs; [
365 sound-theme-freedesktop
368 # Needed for themes and backgrounds
369 environment.pathsToLink = [
370 "/share" # TODO: https://github.com/NixOS/nixpkgs/issues/47173
374 (mkIf serviceCfg.core-shell.enable {
375 services.xserver.desktopManager.gnome.sessionPath =
377 mandatoryPackages = [
378 pkgs.gnome.gnome-shell
381 pkgs.gnome.gnome-shell-extensions
385 ++ utils.removePackagesByName optionalPackages config.environment.gnome.excludePackages;
387 services.colord.enable = mkDefault true;
388 services.gnome.glib-networking.enable = true;
389 services.gnome.gnome-browser-connector.enable = mkDefault true;
390 services.gnome.gnome-initial-setup.enable = mkDefault true;
391 services.gnome.gnome-remote-desktop.enable = mkDefault true;
392 services.gnome.gnome-settings-daemon.enable = true;
393 services.gnome.gnome-user-share.enable = mkDefault true;
394 services.gnome.rygel.enable = mkDefault true;
395 services.gvfs.enable = true;
396 services.system-config-printer.enable = (mkIf config.services.printing.enable (mkDefault true));
398 systemd.packages = with pkgs.gnome; [
403 services.udev.packages = with pkgs.gnome; [
404 # Force enable KMS modifiers for devices that require them.
405 # https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1443
409 services.avahi.enable = mkDefault true;
411 xdg.portal.extraPortals = [
412 pkgs.gnome.gnome-shell
415 services.geoclue2.enable = mkDefault true;
416 services.geoclue2.enableDemoAgent = false; # GNOME has its own geoclue agent
418 services.geoclue2.appConfig.gnome-datetime-panel = {
422 services.geoclue2.appConfig.gnome-color-panel = {
426 services.geoclue2.appConfig."org.gnome.Shell" = {
431 fonts.packages = with pkgs; [
434 source-code-pro # Default monospace font in 3.32
438 # Adapt from https://gitlab.gnome.org/GNOME/gnome-build-meta/blob/gnome-3-38/elements/core/meta-gnome-core-shell.bst
439 environment.systemPackages =
441 mandatoryPackages = with pkgs.gnome; [
444 optionalPackages = with pkgs.gnome; [
446 nixos-background-info
451 gnome-shell-extensions
453 pkgs.gnome-tour # GNOME Shell detects the .desktop file on first log-in.
456 pkgs.glib # for gsettings program
458 pkgs.gtk3.out # for gtk-launch program
459 pkgs.xdg-user-dirs # Update user dirs as described in https://freedesktop.org/wiki/Software/xdg-user-dirs/
463 ++ utils.removePackagesByName optionalPackages config.environment.gnome.excludePackages;
466 # Adapt from https://gitlab.gnome.org/GNOME/gnome-build-meta/-/blob/gnome-45/elements/core/meta-gnome-core-utilities.bst
467 (mkIf serviceCfg.core-utilities.enable {
468 environment.systemPackages =
470 utils.removePackagesByName
474 pkgs.gnome-text-editor
489 pkgs.gnome-connections
494 ] ++ lib.optionals config.services.flatpak.enable [
495 # Since PackageKit Nix support is not there yet,
496 # only install gnome-software if flatpak is enabled.
499 config.environment.gnome.excludePackages;
501 # Enable default program modules
502 # Since some of these have a corresponding package, we only
503 # enable that program module if the package hasn't been excluded
504 # through `environment.gnome.excludePackages`
505 programs.evince.enable = notExcluded pkgs.gnome.evince;
506 programs.file-roller.enable = notExcluded pkgs.gnome.file-roller;
507 programs.geary.enable = notExcluded pkgs.gnome.geary;
508 programs.gnome-disks.enable = notExcluded pkgs.gnome.gnome-disk-utility;
509 programs.seahorse.enable = notExcluded pkgs.gnome.seahorse;
510 services.gnome.sushi.enable = notExcluded pkgs.gnome.sushi;
512 # VTE shell integration for gnome-console
513 programs.bash.vteIntegration = mkDefault true;
514 programs.zsh.vteIntegration = mkDefault true;
516 # Let nautilus find extensions
517 # TODO: Create nautilus-with-extensions package
518 environment.sessionVariables.NAUTILUS_4_EXTENSION_DIR = "${config.system.path}/lib/nautilus/extensions-4";
520 # Override default mimeapps for nautilus
521 environment.sessionVariables.XDG_DATA_DIRS = [ "${mimeAppsList}/share" ];
523 environment.pathsToLink = [
524 "/share/nautilus-python/extensions"
528 (mkIf serviceCfg.games.enable {
529 environment.systemPackages = with pkgs.gnome; utils.removePackagesByName [
550 ] config.environment.gnome.excludePackages;
553 # Adapt from https://gitlab.gnome.org/GNOME/gnome-build-meta/-/blob/3.38.0/elements/core/meta-gnome-core-developer-tools.bst
554 (mkIf serviceCfg.core-developer-tools.enable {
555 environment.systemPackages = with pkgs.gnome; utils.removePackagesByName [
559 # boxes would make sense in this option, however
560 # it doesn't function well enough to be included
561 # in default configurations.
562 # https://github.com/NixOS/nixpkgs/issues/60908
564 ] config.environment.gnome.excludePackages;
566 services.sysprof.enable = notExcluded pkgs.sysprof;