Merge pull request #259363 from bobby285271/fix/gnome-flashback

gnome.gnome-flashback: Fix x-d-p-gnome launch
This commit is contained in:
Bobby Rong 2023-10-07 20:56:26 +08:00 committed by GitHub
commit 383b753bba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 110 additions and 81 deletions

View file

@ -229,7 +229,7 @@ in
panelModulePackages = mkOption { panelModulePackages = mkOption {
default = [ pkgs.gnome.gnome-applets ]; default = [ pkgs.gnome.gnome-applets ];
defaultText = literalExpression "[ pkgs.gnome.gnome-applets ]"; defaultText = literalExpression "[ pkgs.gnome.gnome-applets ]";
type = types.listOf types.path; type = types.listOf types.package;
description = lib.mdDoc '' description = lib.mdDoc ''
Packages containing modules that should be made available to `gnome-panel` (usually for applets). Packages containing modules that should be made available to `gnome-panel` (usually for applets).
@ -294,8 +294,7 @@ in
map map
(wm: (wm:
pkgs.gnome.gnome-flashback.mkSessionForWm { pkgs.gnome.gnome-flashback.mkSessionForWm {
inherit (wm) wmName wmLabel wmCommand enableGnomePanel; inherit (wm) wmName wmLabel wmCommand;
inherit (cfg.flashback) panelModulePackages;
} }
) flashbackWms; ) flashbackWms;
@ -309,7 +308,14 @@ in
environment.systemPackages = with pkgs.gnome; [ environment.systemPackages = with pkgs.gnome; [
gnome-flashback gnome-flashback
]; (gnome-panel-with-modules.override {
panelModulePackages = cfg.flashback.panelModulePackages;
})
]
# For /share/applications/${wmName}.desktop
++ (map (wm: gnome-flashback.mkWmApplication { inherit (wm) wmName wmLabel wmCommand; }) flashbackWms)
# For /share/gnome-session/sessions/gnome-flashback-${wmName}.session
++ (map (wm: gnome-flashback.mkGnomeSession { inherit (wm) wmName wmLabel enableGnomePanel; }) flashbackWms);
}) })
(mkIf serviceCfg.core-os-services.enable { (mkIf serviceCfg.core-os-services.enable {

View file

@ -32,14 +32,7 @@ import ./make-test-python.nix ({ pkgs, lib, ...} : {
xauthority = "/run/user/${uid}/gdm/Xauthority"; xauthority = "/run/user/${uid}/gdm/Xauthority";
in '' in ''
with subtest("Login to GNOME Flashback with GDM"): with subtest("Login to GNOME Flashback with GDM"):
# wait_for_x() checks graphical-session.target, which is expected to be machine.wait_for_x()
# inactive on gnome-flashback before #228946 (i.e. systemd managed
# gnome-session) is done.
# https://github.com/NixOS/nixpkgs/pull/208060
#
# Previously this was unconditionally touched by xsessionWrapper but was
# changed in #233981 (we have GNOME-Flashback:GNOME in XDG_CURRENT_DESKTOP).
# machine.wait_for_x()
machine.wait_until_succeeds('journalctl -t gnome-session-binary --grep "Entering running state"') machine.wait_until_succeeds('journalctl -t gnome-session-binary --grep "Entering running state"')
# Wait for alice to be logged in" # Wait for alice to be logged in"
machine.wait_for_unit("default.target", "${user.name}") machine.wait_for_unit("default.target", "${user.name}")

View file

@ -238,9 +238,9 @@ lib.makeScope pkgs.newScope (self: with self; {
gnome-flashback = callPackage ./misc/gnome-flashback { }; gnome-flashback = callPackage ./misc/gnome-flashback { };
gnome-panel = callPackage ./misc/gnome-panel { gnome-panel = callPackage ./misc/gnome-panel { };
autoreconfHook = pkgs.autoreconfHook269;
}; gnome-panel-with-modules = callPackage ./misc/gnome-panel/wrapper.nix { };
gnome-tweaks = callPackage ./misc/gnome-tweaks { }; gnome-tweaks = callPackage ./misc/gnome-tweaks { };

View file

@ -127,72 +127,36 @@ let
versionPolicy = "odd-unstable"; versionPolicy = "odd-unstable";
}; };
mkSessionForWm = { wmName, wmLabel, wmCommand, enableGnomePanel, panelModulePackages }: mkWmApplication = { wmName, wmLabel, wmCommand }:
let writeTextFile {
wmApplication = writeTextFile { name = "gnome-flashback-${wmName}-wm";
name = "gnome-flashback-${wmName}-wm"; destination = "/share/applications/${wmName}.desktop";
destination = "/share/applications/${wmName}.desktop"; text = ''
text = '' [Desktop Entry]
[Desktop Entry] Type=Application
Type=Application Encoding=UTF-8
Encoding=UTF-8 Name=${wmLabel}
Name=${wmLabel} Exec=${wmCommand}
Exec=${wmCommand} NoDisplay=true
NoDisplay=true X-GNOME-WMName=${wmLabel}
X-GNOME-WMName=${wmLabel} X-GNOME-Autostart-Phase=WindowManager
X-GNOME-Autostart-Phase=WindowManager X-GNOME-Provides=windowmanager
X-GNOME-Provides=windowmanager X-GNOME-Autostart-Notify=false
X-GNOME-Autostart-Notify=false '';
''; };
};
gnomeSession = writeTextFile { mkGnomeSession = { wmName, wmLabel, enableGnomePanel }:
name = "gnome-flashback-${wmName}-gnome-session"; writeTextFile {
destination = "/share/gnome-session/sessions/gnome-flashback-${wmName}.session"; name = "gnome-flashback-${wmName}-gnome-session";
text = '' destination = "/share/gnome-session/sessions/gnome-flashback-${wmName}.session";
[GNOME Session] text = ''
Name=GNOME Flashback (${wmLabel}) [GNOME Session]
${requiredComponents wmName enableGnomePanel} Name=GNOME Flashback (${wmLabel})
''; ${requiredComponents wmName enableGnomePanel}
}; '';
};
# gnome-panel will only look for applets in a single directory so symlink them into here. mkSessionForWm = { wmName, wmLabel, wmCommand }:
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" ];
};
executable = stdenv.mkDerivation {
name = "gnome-flashback-${wmName}";
nativeBuildInputs = [ glib wrapGAppsHook ];
buildInputs = [ gnome-flashback ] ++ lib.optionals enableGnomePanel ([ gnome-panel ] ++ panelModulePackages);
# 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.
# We need to pass the --builtin flag so that gnome-session invokes gnome-session-binary instead of systemd.
# If systemd is used, it doesn't use the environment we set up here and so it can't find the .desktop files.
preFixup = ''
makeWrapper ${gnome-session}/bin/gnome-session $out \
--add-flags "--session=gnome-flashback-${wmName} --builtin" \
--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 writeTextFile
{ {
name = "gnome-flashback-${wmName}-xsession"; name = "gnome-flashback-${wmName}-xsession";
@ -201,7 +165,7 @@ let
[Desktop Entry] [Desktop Entry]
Name=GNOME Flashback (${wmLabel}) Name=GNOME Flashback (${wmLabel})
Comment=This session logs you into GNOME Flashback with ${wmLabel} Comment=This session logs you into GNOME Flashback with ${wmLabel}
Exec=${executable} Exec=${gnome-session}/bin/gnome-session --session=gnome-flashback-${wmName}
TryExec=${wmCommand} TryExec=${wmCommand}
Type=Application Type=Application
DesktopNames=GNOME-Flashback;GNOME; DesktopNames=GNOME-Flashback;GNOME;
@ -211,7 +175,7 @@ let
}; };
mkSystemdTargetForWm = { wmName, wmLabel, wmCommand, enableGnomePanel }: mkSystemdTargetForWm = { wmName, wmLabel, wmCommand, enableGnomePanel }:
runCommand "gnome-flashback-${wmName}.target" {} '' runCommand "gnome-flashback-${wmName}.target" { } ''
mkdir -p $out/lib/systemd/user mkdir -p $out/lib/systemd/user
cp -r "${gnome-flashback}/lib/systemd/user/gnome-session@gnome-flashback-metacity.target.d" \ cp -r "${gnome-flashback}/lib/systemd/user/gnome-session@gnome-flashback-metacity.target.d" \
"$out/lib/systemd/user/gnome-session@gnome-flashback-${wmName}.target.d" "$out/lib/systemd/user/gnome-session@gnome-flashback-${wmName}.target.d"

View file

@ -0,0 +1,66 @@
{ stdenv
, lib
, buildEnv
, gnome-panel
, gnome-flashback
, xorg
, glib
, wrapGAppsHook
, panelModulePackages ? [ ]
}:
let
# We always want to find the built-in panel applets.
selectedPanelModulePackages = [ gnome-panel gnome-flashback ] ++ panelModulePackages;
panelModulesEnv = buildEnv {
name = "gnome-panel-modules-env";
paths = selectedPanelModulePackages;
pathsToLink = [ "/lib/gnome-panel/modules" ];
};
in
stdenv.mkDerivation {
pname = "${gnome-panel.pname}-with-modules";
inherit (gnome-panel) version;
nativeBuildInputs = [
glib
wrapGAppsHook
];
buildInputs = selectedPanelModulePackages ++
lib.forEach selectedPanelModulePackages (x: x.buildInputs or [ ]);
dontUnpack = true;
dontConfigure = true;
dontBuild = true;
preferLocalBuild = true;
allowSubstitutes = false;
installPhase = ''
runHook preInstall
mkdir -p $out
${xorg.lndir}/bin/lndir -silent ${gnome-panel} $out
rm -r $out/lib/gnome-panel/modules
${xorg.lndir}/bin/lndir -silent ${panelModulesEnv} $out
rm $out/share/applications/gnome-panel.desktop
substitute ${gnome-panel}/share/applications/gnome-panel.desktop \
$out/share/applications/gnome-panel.desktop --replace \
"Exec=${gnome-panel}/bin/gnome-panel" "Exec=$out/bin/gnome-panel"
runHook postInstall
'';
preFixup = ''
gappsWrapperArgs+=(
--set NIX_GNOME_PANEL_MODULESDIR "$out/lib/gnome-panel/modules"
)
'';
meta = gnome-panel.meta // { outputsToInstall = [ "out" ]; };
}