Merge pull request #125180 from chpatrick/gnome-flashback-panel-modules
gnome-flashback: add module support to gnome-panel for installing applets
This commit is contained in:
commit
ab0d28758e
4 changed files with 84 additions and 10 deletions
|
@ -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 <literal>gnome-panel</literal> (usually for applets).
|
||||
|
||||
If you're packaging something to use here, please install the modules in <literal>$out/lib/gnome-panel/modules</literal>.
|
||||
'';
|
||||
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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 <<END_PATCH
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
diff --git a/gnome-panel/gp-module-manager.c b/gnome-panel/gp-module-manager.c
|
||||
index 58447fd84..7af99de7d 100644
|
||||
--- a/gnome-panel/gp-module-manager.c
|
||||
+++ b/gnome-panel/gp-module-manager.c
|
||||
@@ -49,8 +49,16 @@ load_modules (GpModuleManager *self)
|
||||
{
|
||||
GDir *dir;
|
||||
const gchar *name;
|
||||
+ const gchar *modules_dir;
|
||||
|
||||
- dir = g_dir_open (MODULESDIR, 0, NULL);
|
||||
+ modules_dir = g_getenv ("NIX_GNOME_PANEL_MODULESDIR");
|
||||
+
|
||||
+ if (!modules_dir) {
|
||||
+ g_warning ("The NIX_GNOME_PANEL_MODULESDIR environment variable was not set, modules will not be loaded.");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ dir = g_dir_open (modules_dir, 0, NULL);
|
||||
if (!dir)
|
||||
return;
|
||||
|
||||
@@ -63,7 +71,7 @@ load_modules (GpModuleManager *self)
|
||||
if (!g_str_has_suffix (name, ".so"))
|
||||
continue;
|
||||
|
||||
- path = g_build_filename (MODULESDIR, name, NULL);
|
||||
+ path = g_build_filename (modules_dir, name, NULL);
|
||||
module = gp_module_new_from_path (path);
|
||||
g_free (path);
|
||||
|
Loading…
Reference in a new issue