fix: launch gpgui outside Nix FHS environment

This commit is contained in:
Kevin Yue committed 2026-07-30 21:06:43 +08:00
1 parent 0a528b4aae
commit 6999b2725e
1 file changed
+52 -6
+52 -6
View File
@@ -248,8 +248,48 @@
''; '';
}; };
hostGuiLauncher = pkgs.writeShellScript "gpgui-host-launcher" ''
set -eu
if [ "''${1:-}" = "--version" ]; then
exec ${prebuiltFiles}/bin/gpgui "$@"
fi
systemd_run_args=(
--user
--pipe
--wait
--quiet
--collect
--service-type=exec
)
while IFS= read -r env_name; do
case "$env_name" in
*[!A-Za-z0-9_]* | [0-9]* | PATH | GP_VPNC_SCRIPT_INSTALLER_BINARY | INVOCATION_ID | JOURNAL_STREAM | LISTEN_* | NOTIFY_SOCKET | SYSTEMD_EXEC_PID)
continue
;;
esac
systemd_run_args+=("--setenv=$env_name")
done < <(compgen -e)
gui_path="/run/wrappers/bin:''${PATH:-}"
systemd_run_args+=(
"--setenv=PATH=$gui_path"
"--setenv=GP_VPNC_SCRIPT_INSTALLER_BINARY=${prebuiltFiles}/libexec/gpclient/gp-vpnc-script-installer"
)
exec ${pkgs.systemd}/bin/systemd-run \
"''${systemd_run_args[@]}" \
${prebuiltFiles}/bin/gpgui \
"$@"
'';
prebuiltCommand = prebuiltCommand =
binaryName: {
binaryName,
extraProfile ? "",
}:
pkgs.buildFHSEnv { pkgs.buildFHSEnv {
name = binaryName; name = binaryName;
targetPkgs = pkgs: [ prebuiltFiles ] ++ linuxBuildInputs ++ linuxRuntimeDependencies; targetPkgs = pkgs: [ prebuiltFiles ] ++ linuxBuildInputs ++ linuxRuntimeDependencies;
@@ -257,6 +297,7 @@
profile = '' profile = ''
export PATH=/run/wrappers/bin:$PATH export PATH=/run/wrappers/bin:$PATH
export GP_VPNC_SCRIPT_INSTALLER_BINARY='${prebuiltFiles}/libexec/gpclient/gp-vpnc-script-installer' export GP_VPNC_SCRIPT_INSTALLER_BINARY='${prebuiltFiles}/libexec/gpclient/gp-vpnc-script-installer'
${extraProfile}
''; '';
extraBwrapArgs = [ extraBwrapArgs = [
"--bind-try" "--bind-try"
@@ -269,11 +310,16 @@
}; };
prebuiltCommands = { prebuiltCommands = {
gpclient = prebuiltCommand "gpclient"; gpclient = prebuiltCommand { binaryName = "gpclient"; };
gpservice = prebuiltCommand "gpservice"; gpservice = prebuiltCommand {
gpauth = prebuiltCommand "gpauth"; binaryName = "gpservice";
gpgui = prebuiltCommand "gpgui"; extraProfile = ''
gpgui-helper = prebuiltCommand "gpgui-helper"; export GP_GUI_BINARY='${hostGuiLauncher}'
'';
};
gpauth = prebuiltCommand { binaryName = "gpauth"; };
gpgui = prebuiltCommand { binaryName = "gpgui"; };
gpgui-helper = prebuiltCommand { binaryName = "gpgui-helper"; };
}; };
prebuilt = pkgs.stdenv.mkDerivation { prebuilt = pkgs.stdenv.mkDerivation {