diff --git a/nixos/modules/services/x11/desktop-managers/gnome.nix b/nixos/modules/services/x11/desktop-managers/gnome.nix index 37e61f32823d..2b2ee019aeb2 100644 --- a/nixos/modules/services/x11/desktop-managers/gnome.nix +++ b/nixos/modules/services/x11/desktop-managers/gnome.nix @@ -256,6 +256,17 @@ in default = []; description = "Other GNOME Flashback sessions to enable."; }; + + panelModulePackages = mkOption { + default = [ pkgs.gnome.gnome-applets ]; + type = types.listOf types.path; + description = '' + Packages containing modules that should be made available to gnome-panel (usually for applets). + + If you're packaging something to use here, please install the modules in $out/lib/gnome-panel/modules. + ''; + example = literalExample "[ pkgs.gnome.gnome-applets ]"; + }; }; }; @@ -318,6 +329,7 @@ in (wm: pkgs.gnome.gnome-flashback.mkSessionForWm { inherit (wm) wmName wmLabel wmCommand enableGnomePanel; + inherit (cfg.flashback) panelModulePackages; } ) flashbackWms; diff --git a/pkgs/desktops/gnome/misc/gnome-flashback/default.nix b/pkgs/desktops/gnome/misc/gnome-flashback/default.nix index 2e8662ede0c7..3df9d7450cd7 100644 --- a/pkgs/desktops/gnome/misc/gnome-flashback/default.nix +++ b/pkgs/desktops/gnome/misc/gnome-flashback/default.nix @@ -23,10 +23,10 @@ , pam , wrapGAppsHook , writeTextFile -, writeShellScriptBin , xkeyboard_config , xorg , runCommand +, buildEnv }: let pname = "gnome-flashback"; @@ -126,7 +126,7 @@ let versionPolicy = "odd-unstable"; }; - mkSessionForWm = { wmName, wmLabel, wmCommand, enableGnomePanel }: + mkSessionForWm = { wmName, wmLabel, wmCommand, enableGnomePanel, panelModulePackages }: let wmApplication = writeTextFile { name = "gnome-flashback-${wmName}-wm"; @@ -155,15 +155,39 @@ let ''; }; - executable = writeShellScriptBin "gnome-flashback-${wmName}" '' - if [ -z $XDG_CURRENT_DESKTOP ]; then - export XDG_CURRENT_DESKTOP="GNOME-Flashback:GNOME" - fi + # gnome-panel will only look for applets in a single directory so symlink them into here. + panelModulesEnv = buildEnv { + name = "gnome-panel-modules-env"; + # We always want to find the built-in panel applets. + paths = [ gnome-panel gnome-flashback ] ++ panelModulePackages; + pathsToLink = [ "/lib/gnome-panel/modules" ]; + }; - export XDG_DATA_DIRS=${wmApplication}/share:${gnomeSession}/share:${gnome-flashback}/share:${gnome-panel}/share:$XDG_DATA_DIRS + executable = stdenv.mkDerivation { + name = "gnome-flashback-${wmName}"; + nativeBuildInputs = [ glib wrapGAppsHook ]; + buildInputs = [ gnome-flashback ] ++ lib.optionals enableGnomePanel ([ gnome-panel ] ++ panelModulePackages); - exec ${gnome-session}/bin/gnome-session --session=gnome-flashback-${wmName} "$@" - ''; + # We want to use the wrapGAppsHook mechanism to wrap gnome-session + # with the environment that gnome-flashback and gnome-panel need to + # run, including the configured applet packages. This is only possible + # in the fixup phase, so turn everything else off. + dontUnpack = true; + dontConfigure = true; + dontBuild = true; + dontInstall = true; + dontWrapGApps = true; # We want to do the wrapping ourselves. + + # gnome-flashback and gnome-panel need to be added to XDG_DATA_DIRS so that their .desktop files can be found by gnome-session. + preFixup = '' + makeWrapper ${gnome-session}/bin/gnome-session $out \ + --add-flags "--session=gnome-flashback-${wmName}" \ + --set-default XDG_CURRENT_DESKTOP 'GNOME-Flashback:GNOME' \ + --prefix XDG_DATA_DIRS : '${lib.makeSearchPath "share" ([ wmApplication gnomeSession gnome-flashback ] ++ lib.optional enableGnomePanel gnome-panel)}' \ + "''${gappsWrapperArgs[@]}" \ + ${lib.optionalString enableGnomePanel "--set NIX_GNOME_PANEL_MODULESDIR '${panelModulesEnv}/lib/gnome-panel/modules'"} + ''; + }; in writeTextFile @@ -174,7 +198,7 @@ let [Desktop Entry] Name=GNOME Flashback (${wmLabel}) Comment=This session logs you into GNOME Flashback with ${wmLabel} - Exec=${executable}/bin/gnome-flashback-${wmName} + Exec=${executable} TryExec=${wmCommand} Type=Application DesktopNames=GNOME-Flashback;GNOME; diff --git a/pkgs/desktops/gnome/misc/gnome-panel/default.nix b/pkgs/desktops/gnome/misc/gnome-panel/default.nix index 4e42f91e1e3c..8ab1a87d01ce 100644 --- a/pkgs/desktops/gnome/misc/gnome-panel/default.nix +++ b/pkgs/desktops/gnome/misc/gnome-panel/default.nix @@ -32,6 +32,13 @@ stdenv.mkDerivation rec { hash = "sha256-nxNQde3GZs8rnKkd41xnA+KxdxwQp3B0FPtlbCilmzs="; }; + patches = [ + # Load modules from path in `NIX_GNOME_PANEL_MODULESDIR` environment variable + # instead of gnome-panel’s libdir so that the NixOS module can make gnome-panel + # load modules from other packages as well. + ./modulesdir-env-var.patch + ]; + # make .desktop Exec absolute postPatch = '' patch -p0 <