Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

gnome-flashback: add module support to gnome-panel for installing applets

Co-authored-by: Jan Tojnar <jtojnar@gmail.com>

+84 -10
+12
nixos/modules/services/x11/desktop-managers/gnome.nix
··· 261 default = []; 262 description = "Other GNOME Flashback sessions to enable."; 263 }; 264 }; 265 }; 266 ··· 323 (wm: 324 pkgs.gnome.gnome-flashback.mkSessionForWm { 325 inherit (wm) wmName wmLabel wmCommand enableGnomePanel; 326 } 327 ) flashbackWms; 328
··· 261 default = []; 262 description = "Other GNOME Flashback sessions to enable."; 263 }; 264 + 265 + panelModulePackages = mkOption { 266 + default = [ pkgs.gnome.gnome-applets ]; 267 + type = types.listOf types.path; 268 + description = '' 269 + Packages containing modules that should be made available to <literal>gnome-panel</literal> (usually for applets). 270 + 271 + If you're packaging something to use here, please install the modules in <literal>$out/lib/gnome-panel/modules</literal>. 272 + ''; 273 + example = literalExample "[ pkgs.gnome.gnome-applets ]"; 274 + }; 275 }; 276 }; 277 ··· 334 (wm: 335 pkgs.gnome.gnome-flashback.mkSessionForWm { 336 inherit (wm) wmName wmLabel wmCommand enableGnomePanel; 337 + inherit (cfg.flashback) panelModulePackages; 338 } 339 ) flashbackWms; 340
+34 -10
pkgs/desktops/gnome/misc/gnome-flashback/default.nix
··· 23 , pam 24 , wrapGAppsHook 25 , writeTextFile 26 - , writeShellScriptBin 27 , xkeyboard_config 28 , xorg 29 , runCommand 30 }: 31 let 32 pname = "gnome-flashback"; ··· 126 versionPolicy = "odd-unstable"; 127 }; 128 129 - mkSessionForWm = { wmName, wmLabel, wmCommand, enableGnomePanel }: 130 let 131 wmApplication = writeTextFile { 132 name = "gnome-flashback-${wmName}-wm"; ··· 155 ''; 156 }; 157 158 - executable = writeShellScriptBin "gnome-flashback-${wmName}" '' 159 - if [ -z $XDG_CURRENT_DESKTOP ]; then 160 - export XDG_CURRENT_DESKTOP="GNOME-Flashback:GNOME" 161 - fi 162 163 - export XDG_DATA_DIRS=${wmApplication}/share:${gnomeSession}/share:${gnome-flashback}/share:${gnome-panel}/share:$XDG_DATA_DIRS 164 165 - exec ${gnome-session}/bin/gnome-session --session=gnome-flashback-${wmName} "$@" 166 - ''; 167 168 in 169 writeTextFile ··· 174 [Desktop Entry] 175 Name=GNOME Flashback (${wmLabel}) 176 Comment=This session logs you into GNOME Flashback with ${wmLabel} 177 - Exec=${executable}/bin/gnome-flashback-${wmName} 178 TryExec=${wmCommand} 179 Type=Application 180 DesktopNames=GNOME-Flashback;GNOME;
··· 23 , pam 24 , wrapGAppsHook 25 , writeTextFile 26 , xkeyboard_config 27 , xorg 28 , runCommand 29 + , buildEnv 30 }: 31 let 32 pname = "gnome-flashback"; ··· 126 versionPolicy = "odd-unstable"; 127 }; 128 129 + mkSessionForWm = { wmName, wmLabel, wmCommand, enableGnomePanel, panelModulePackages }: 130 let 131 wmApplication = writeTextFile { 132 name = "gnome-flashback-${wmName}-wm"; ··· 155 ''; 156 }; 157 158 + # gnome-panel will only look for applets in a single directory so symlink them into here. 159 + panelModulesEnv = buildEnv { 160 + name = "gnome-panel-modules-env"; 161 + # We always want to find the built-in panel applets. 162 + paths = [ gnome-panel gnome-flashback ] ++ panelModulePackages; 163 + pathsToLink = [ "/lib/gnome-panel/modules" ]; 164 + }; 165 166 + executable = stdenv.mkDerivation { 167 + name = "gnome-flashback-${wmName}"; 168 + nativeBuildInputs = [ glib wrapGAppsHook ]; 169 + buildInputs = [ gnome-flashback ] ++ lib.optionals enableGnomePanel ([ gnome-panel ] ++ panelModulePackages); 170 171 + # We want to use the wrapGAppsHook mechanism to wrap gnome-session 172 + # with the environment that gnome-flashback and gnome-panel need to 173 + # run, including the configured applet packages. This is only possible 174 + # in the fixup phase, so turn everything else off. 175 + dontUnpack = true; 176 + dontConfigure = true; 177 + dontBuild = true; 178 + dontInstall = true; 179 + dontWrapGApps = true; # We want to do the wrapping ourselves. 180 + 181 + # gnome-flashback and gnome-panel need to be added to XDG_DATA_DIRS so that their .desktop files can be found by gnome-session. 182 + preFixup = '' 183 + makeWrapper ${gnome-session}/bin/gnome-session $out \ 184 + --add-flags "--session=gnome-flashback-${wmName}" \ 185 + --set-default XDG_CURRENT_DESKTOP 'GNOME-Flashback:GNOME' \ 186 + --prefix XDG_DATA_DIRS : '${lib.makeSearchPath "share" ([ wmApplication gnomeSession gnome-flashback ] ++ lib.optional enableGnomePanel gnome-panel)}' \ 187 + "''${gappsWrapperArgs[@]}" \ 188 + ${lib.optionalString enableGnomePanel "--set NIX_GNOME_PANEL_MODULESDIR '${panelModulesEnv}/lib/gnome-panel/modules'"} 189 + ''; 190 + }; 191 192 in 193 writeTextFile ··· 198 [Desktop Entry] 199 Name=GNOME Flashback (${wmLabel}) 200 Comment=This session logs you into GNOME Flashback with ${wmLabel} 201 + Exec=${executable} 202 TryExec=${wmCommand} 203 Type=Application 204 DesktopNames=GNOME-Flashback;GNOME;
+7
pkgs/desktops/gnome/misc/gnome-panel/default.nix
··· 32 hash = "sha256-nxNQde3GZs8rnKkd41xnA+KxdxwQp3B0FPtlbCilmzs="; 33 }; 34 35 # make .desktop Exec absolute 36 postPatch = '' 37 patch -p0 <<END_PATCH
··· 32 hash = "sha256-nxNQde3GZs8rnKkd41xnA+KxdxwQp3B0FPtlbCilmzs="; 33 }; 34 35 + patches = [ 36 + # Load modules from path in `NIX_GNOME_PANEL_MODULESDIR` environment variable 37 + # instead of gnome-panel’s libdir so that the NixOS module can make gnome-panel 38 + # load modules from other packages as well. 39 + ./modulesdir-env-var.patch 40 + ]; 41 + 42 # make .desktop Exec absolute 43 postPatch = '' 44 patch -p0 <<END_PATCH
+31
pkgs/desktops/gnome/misc/gnome-panel/modulesdir-env-var.patch
···
··· 1 + diff --git a/gnome-panel/gp-module-manager.c b/gnome-panel/gp-module-manager.c 2 + index 58447fd84..7af99de7d 100644 3 + --- a/gnome-panel/gp-module-manager.c 4 + +++ b/gnome-panel/gp-module-manager.c 5 + @@ -49,8 +49,16 @@ load_modules (GpModuleManager *self) 6 + { 7 + GDir *dir; 8 + const gchar *name; 9 + + const gchar *modules_dir; 10 + 11 + - dir = g_dir_open (MODULESDIR, 0, NULL); 12 + + modules_dir = g_getenv ("NIX_GNOME_PANEL_MODULESDIR"); 13 + + 14 + + if (!modules_dir) { 15 + + g_warning ("The NIX_GNOME_PANEL_MODULESDIR environment variable was not set, modules will not be loaded."); 16 + + return; 17 + + } 18 + + 19 + + dir = g_dir_open (modules_dir, 0, NULL); 20 + if (!dir) 21 + return; 22 + 23 + @@ -63,7 +71,7 @@ load_modules (GpModuleManager *self) 24 + if (!g_str_has_suffix (name, ".so")) 25 + continue; 26 + 27 + - path = g_build_filename (MODULESDIR, name, NULL); 28 + + path = g_build_filename (modules_dir, name, NULL); 29 + module = gp_module_new_from_path (path); 30 + g_free (path); 31 +