1 { config, lib, pkgs, utils, ... }:
4 inherit (lib) mkOption types mkDefault mkEnableOption literalExpression;
6 cfg = config.services.xserver.desktopManager.gnome;
7 serviceCfg = config.services.gnome;
9 # Prioritize nautilus by default when opening directories
10 mimeAppsList = pkgs.writeTextFile {
11 name = "gnome-mimeapps";
12 destination = "/share/applications/mimeapps.list";
14 [Default Applications]
15 inode/directory=nautilus.desktop;org.gnome.Nautilus.desktop
19 defaultFavoriteAppsOverride = ''
21 favorite-apps=[ 'org.gnome.Epiphany.desktop', 'org.gnome.Geary.desktop', 'org.gnome.Calendar.desktop', 'org.gnome.Music.desktop', 'org.gnome.Nautilus.desktop' ]
24 nixos-background-light = pkgs.nixos-artwork.wallpapers.simple-blue;
25 nixos-background-dark = pkgs.nixos-artwork.wallpapers.simple-dark-gray;
27 # TODO: Having https://github.com/NixOS/nixpkgs/issues/54150 would supersede this
28 nixos-gsettings-desktop-schemas = pkgs.gnome.nixos-gsettings-overrides.override {
29 inherit (cfg) extraGSettingsOverrides extraGSettingsOverridePackages favoriteAppsOverride;
30 inherit flashbackEnabled nixos-background-dark nixos-background-light;
33 nixos-background-info = pkgs.writeTextFile rec {
34 name = "nixos-background-info";
37 <!DOCTYPE wallpapers SYSTEM "gnome-wp-list.dtd">
39 <wallpaper deleted="false">
41 <filename>${nixos-background-light.gnomeFilePath}</filename>
42 <filename-dark>${nixos-background-dark.gnomeFilePath}</filename-dark>
43 <options>zoom</options>
44 <shade_type>solid</shade_type>
45 <pcolor>#3a4ba0</pcolor>
46 <scolor>#2f302f</scolor>
50 destination = "/share/gnome-background-properties/nixos.xml";
53 flashbackEnabled = cfg.flashback.enableMetacity || lib.length cfg.flashback.customSessions > 0;
54 flashbackWms = lib.optional cfg.flashback.enableMetacity {
57 wmCommand = "${pkgs.metacity}/bin/metacity";
58 enableGnomePanel = true;
59 } ++ cfg.flashback.customSessions;
61 notExcluded = pkg: mkDefault (!(lib.elem pkg config.environment.gnome.excludePackages));
69 maintainers = lib.teams.gnome.members;
75 core-os-services.enable = mkEnableOption "essential services for GNOME3";
76 core-shell.enable = mkEnableOption "GNOME Shell services";
77 core-utilities.enable = mkEnableOption "GNOME core utilities";
78 core-developer-tools.enable = mkEnableOption "GNOME core developer tools";
79 games.enable = mkEnableOption "GNOME games";
82 services.xserver.desktopManager.gnome = {
86 description = "Enable GNOME desktop manager.";
89 sessionPath = mkOption {
91 type = types.listOf types.package;
92 example = literalExpression "[ pkgs.gpaste ]";
94 Additional list of packages to be added to the session search path.
95 Useful for GNOME Shell extensions or GSettings-conditional autostart.
97 Note that this should be a last resort; patching the package is preferred (see GPaste).
101 favoriteAppsOverride = mkOption {
102 internal = true; # this is messy
103 default = defaultFavoriteAppsOverride;
105 example = literalExpression ''
108 favorite-apps=[ 'firefox.desktop', 'org.gnome.Calendar.desktop' ]
111 description = "List of desktop files to put as favorite apps into pkgs.gnome-shell. These need to be installed somehow globally.";
114 extraGSettingsOverrides = mkOption {
117 description = "Additional gsettings overrides.";
120 extraGSettingsOverridePackages = mkOption {
122 type = types.listOf types.path;
123 description = "List of packages for which gsettings are overridden.";
126 debug = mkEnableOption "pkgs.gnome-session debug messages";
129 enableMetacity = mkEnableOption "the standard GNOME Flashback session with Metacity";
131 customSessions = mkOption {
132 type = types.listOf (types.submodule {
135 type = types.strMatching "[a-zA-Z0-9_-]+";
136 description = "A unique identifier for the window manager.";
142 description = "The name of the window manager to show in the session chooser.";
146 wmCommand = mkOption {
148 description = "The executable of the window manager to use.";
149 example = literalExpression ''"''${pkgs.haskellPackages.xmonad}/bin/xmonad"'';
152 enableGnomePanel = mkOption {
156 description = "Whether to enable the GNOME panel in this session.";
161 description = "Other GNOME Flashback sessions to enable.";
164 panelModulePackages = mkOption {
165 default = [ pkgs.gnome-applets ];
166 defaultText = literalExpression "[ pkgs.gnome-applets ]";
167 type = types.listOf types.package;
169 Packages containing modules that should be made available to `pkgs.gnome-panel` (usually for applets).
171 If you're packaging something to use here, please install the modules in `$out/lib/gnome-panel/modules`.
177 environment.gnome.excludePackages = mkOption {
179 example = literalExpression "[ pkgs.totem ]";
180 type = types.listOf types.package;
181 description = "Which packages gnome should exclude from the default environment";
186 config = lib.mkMerge [
187 (lib.mkIf (cfg.enable || flashbackEnabled) {
188 # Seed our configuration into nixos-generate-config
189 system.nixos-generate-config.desktopConfiguration = [''
190 # Enable the GNOME Desktop Environment.
191 services.xserver.displayManager.gdm.enable = true;
192 services.xserver.desktopManager.gnome.enable = true;
195 services.gnome.core-os-services.enable = true;
196 services.gnome.core-shell.enable = true;
197 services.gnome.core-utilities.enable = mkDefault true;
199 services.displayManager.sessionPackages = [ pkgs.gnome-session.sessions ];
201 environment.extraInit = ''
202 ${lib.concatMapStrings (p: ''
203 if [ -d "${p}/share/gsettings-schemas/${p.name}" ]; then
204 export XDG_DATA_DIRS=$XDG_DATA_DIRS''${XDG_DATA_DIRS:+:}${p}/share/gsettings-schemas/${p.name}
207 if [ -d "${p}/lib/girepository-1.0" ]; then
208 export GI_TYPELIB_PATH=$GI_TYPELIB_PATH''${GI_TYPELIB_PATH:+:}${p}/lib/girepository-1.0
209 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}${p}/lib
214 environment.systemPackages = cfg.sessionPath;
216 environment.sessionVariables.GNOME_SESSION_DEBUG = lib.mkIf cfg.debug "1";
218 # Override GSettings schemas
219 environment.sessionVariables.NIX_GSETTINGS_OVERRIDES_DIR = "${nixos-gsettings-desktop-schemas}/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas";
222 (lib.mkIf flashbackEnabled {
223 services.displayManager.sessionPackages =
225 wmNames = map (wm: wm.wmName) flashbackWms;
226 namesAreUnique = lib.unique wmNames == wmNames;
228 assert (lib.assertMsg namesAreUnique "Flashback WM names must be unique.");
231 pkgs.gnome-flashback.mkSessionForWm {
232 inherit (wm) wmName wmLabel wmCommand;
236 security.pam.services.gnome-flashback = {
237 enableGnomeKeyring = true;
242 ] ++ map pkgs.gnome-flashback.mkSystemdTargetForWm flashbackWms;
244 environment.systemPackages = [
246 (pkgs.gnome-panel-with-modules.override {
247 panelModulePackages = cfg.flashback.panelModulePackages;
250 # For /share/applications/${wmName}.desktop
251 ++ (map (wm: pkgs.gnome-flashback.mkWmApplication { inherit (wm) wmName wmLabel wmCommand; }) flashbackWms)
252 # For /share/pkgs.gnome-session/sessions/gnome-flashback-${wmName}.session
253 ++ (map (wm: pkgs.gnome-flashback.mkGnomeSession { inherit (wm) wmName wmLabel enableGnomePanel; }) flashbackWms);
256 (lib.mkIf serviceCfg.core-os-services.enable {
257 hardware.bluetooth.enable = mkDefault true;
258 programs.dconf.enable = true;
259 security.polkit.enable = true;
260 services.accounts-daemon.enable = true;
261 services.dleyna-renderer.enable = mkDefault true;
262 services.dleyna-server.enable = mkDefault true;
263 services.power-profiles-daemon.enable = mkDefault true;
264 services.gnome.at-spi2-core.enable = true;
265 services.gnome.evolution-data-server.enable = true;
266 services.gnome.gnome-keyring.enable = true;
267 services.gnome.gnome-online-accounts.enable = mkDefault true;
268 services.gnome.tracker-miners.enable = mkDefault true;
269 services.gnome.tracker.enable = mkDefault true;
270 services.hardware.bolt.enable = mkDefault true;
271 # TODO: Enable once #177946 is resolved
272 # services.packagekit.enable = mkDefault true;
273 services.udisks2.enable = true;
274 services.upower.enable = config.powerManagement.enable;
275 services.libinput.enable = mkDefault true; # for controlling touchpad settings via gnome control center
277 # Explicitly enabled since GNOME will be severely broken without these.
278 xdg.mime.enable = true;
279 xdg.icons.enable = true;
281 xdg.portal.enable = true;
282 xdg.portal.extraPortals = [
283 pkgs.xdg-desktop-portal-gnome
284 pkgs.xdg-desktop-portal-gtk
286 xdg.portal.configPackages = mkDefault [ pkgs.gnome-session ];
288 networking.networkmanager.enable = mkDefault true;
290 services.xserver.updateDbusEnvironment = true;
292 # gnome has a custom alert theme but it still
293 # inherits from the freedesktop theme.
294 environment.systemPackages = with pkgs; [
295 sound-theme-freedesktop
298 # Needed for themes and backgrounds
299 environment.pathsToLink = [
300 "/share" # TODO: https://github.com/NixOS/nixpkgs/issues/47173
304 (lib.mkIf serviceCfg.core-shell.enable {
305 services.xserver.desktopManager.gnome.sessionPath =
307 mandatoryPackages = [
311 pkgs.gnome-shell-extensions
315 ++ utils.removePackagesByName optionalPackages config.environment.gnome.excludePackages;
317 services.colord.enable = mkDefault true;
318 services.gnome.glib-networking.enable = true;
319 services.gnome.gnome-browser-connector.enable = mkDefault true;
320 services.gnome.gnome-initial-setup.enable = mkDefault true;
321 services.gnome.gnome-remote-desktop.enable = mkDefault true;
322 services.gnome.gnome-settings-daemon.enable = true;
323 services.gnome.gnome-user-share.enable = mkDefault true;
324 services.gnome.rygel.enable = mkDefault true;
325 services.gvfs.enable = true;
326 services.system-config-printer.enable = (lib.mkIf config.services.printing.enable (mkDefault true));
333 services.udev.packages = [
334 # Force enable KMS modifiers for devices that require them.
335 # https://gitlab.gnome.org/GNOME/pkgs.mutter/-/merge_requests/1443
339 services.avahi.enable = mkDefault true;
341 services.geoclue2.enable = mkDefault true;
342 services.geoclue2.enableDemoAgent = false; # GNOME has its own geoclue agent
344 services.geoclue2.appConfig.gnome-datetime-panel = {
348 services.geoclue2.appConfig.gnome-color-panel = {
352 services.geoclue2.appConfig."org.gnome.Shell" = {
357 services.orca.enable = notExcluded pkgs.orca;
359 fonts.packages = with pkgs; [
362 source-code-pro # Default monospace font in 3.32
366 # Adapt from https://gitlab.gnome.org/GNOME/gnome-build-meta/blob/gnome-3-38/elements/core/meta-gnome-core-shell.bst
367 environment.systemPackages =
369 mandatoryPackages = [
373 pkgs.adwaita-icon-theme
374 nixos-background-info
375 pkgs.gnome-backgrounds
377 pkgs.gnome-color-manager
378 pkgs.gnome-control-center
379 pkgs.gnome-shell-extensions
380 pkgs.gnome-tour # GNOME Shell detects the .desktop file on first log-in.
382 pkgs.glib # for gsettings program
384 pkgs.gtk3.out # for gtk-launch program
385 pkgs.xdg-user-dirs # Update user dirs as described in https://freedesktop.org/wiki/Software/xdg-user-dirs/
389 ++ utils.removePackagesByName optionalPackages config.environment.gnome.excludePackages;
392 # Adapt from https://gitlab.gnome.org/GNOME/gnome-build-meta/-/blob/gnome-45/elements/core/meta-gnome-core-utilities.bst
393 (lib.mkIf serviceCfg.core-utilities.enable {
394 environment.systemPackages =
395 utils.removePackagesByName
399 pkgs.gnome-text-editor
400 pkgs.gnome-calculator
402 pkgs.gnome-characters
406 pkgs.gnome-font-viewer
410 pkgs.gnome-system-monitor
414 pkgs.gnome-connections
419 ] ++ lib.optionals config.services.flatpak.enable [
420 # Since PackageKit Nix support is not there yet,
421 # only install gnome-software if flatpak is enabled.
424 config.environment.gnome.excludePackages;
426 # Enable default program modules
427 # Since some of these have a corresponding package, we only
428 # enable that program module if the package hasn't been excluded
429 # through `environment.gnome.excludePackages`
430 programs.evince.enable = notExcluded pkgs.evince;
431 programs.file-roller.enable = notExcluded pkgs.file-roller;
432 programs.geary.enable = notExcluded pkgs.geary;
433 programs.gnome-disks.enable = notExcluded pkgs.gnome-disk-utility;
434 programs.seahorse.enable = notExcluded pkgs.seahorse;
435 services.gnome.sushi.enable = notExcluded pkgs.sushi;
437 # VTE shell integration for gnome-console
438 programs.bash.vteIntegration = mkDefault true;
439 programs.zsh.vteIntegration = mkDefault true;
441 # Let nautilus find extensions
442 # TODO: Create nautilus-with-extensions package
443 environment.sessionVariables.NAUTILUS_4_EXTENSION_DIR = "${config.system.path}/lib/nautilus/extensions-4";
445 # Override default mimeapps for nautilus
446 environment.sessionVariables.XDG_DATA_DIRS = [ "${mimeAppsList}/share" ];
448 environment.pathsToLink = [
449 "/share/nautilus-python/extensions"
453 (lib.mkIf serviceCfg.games.enable {
454 environment.systemPackages = utils.removePackagesByName [
475 ] config.environment.gnome.excludePackages;
478 # Adapt from https://gitlab.gnome.org/GNOME/gnome-build-meta/-/blob/3.38.0/elements/core/meta-gnome-core-developer-tools.bst
479 (lib.mkIf serviceCfg.core-developer-tools.enable {
480 environment.systemPackages = utils.removePackagesByName [
484 # boxes would make sense in this option, however
485 # it doesn't function well enough to be included
486 # in default configurations.
487 # https://github.com/NixOS/nixpkgs/issues/60908
488 /* pkgs.gnome-boxes */
489 ] config.environment.gnome.excludePackages;
491 services.sysprof.enable = notExcluded pkgs.sysprof;