From a91c04fa64b8e128cad3892723fe343dc4331ee2 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Tue, 29 Sep 2026 12:10:27 +0800 Subject: [PATCH] fix(nix): package HIP runner and script installer --- crates/common/src/binary_paths.rs | 5 ++++- flake.nix | 26 +++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/crates/common/src/binary_paths.rs b/crates/common/src/binary_paths.rs index 94eb15a..f2f8bdf 100644 --- a/crates/common/src/binary_paths.rs +++ b/crates/common/src/binary_paths.rs @@ -33,7 +33,10 @@ pub fn gp_vpnc_script_installer() -> PathBuf { #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))] pub fn gp_hip_script_installer() -> PathBuf { - PathBuf::from(GP_HIP_SCRIPT_INSTALLER_BINARY) + env::var_os("GP_HIP_SCRIPT_INSTALLER_BINARY") + .filter(|value| !value.is_empty()) + .map(PathBuf::from) + .unwrap_or_else(|| PathBuf::from(GP_HIP_SCRIPT_INSTALLER_BINARY)) } pub fn gpauth() -> PathBuf { diff --git a/flake.nix b/flake.nix index 6198a5f..1a13bd9 100644 --- a/flake.nix +++ b/flake.nix @@ -133,6 +133,11 @@ --replace-fail /usr/bin/gpservice $out/bin/gpservice \ --replace-fail /usr/libexec/gpclient/gp-vpnc-script-installer $out/bin/gp-vpnc-script-installer + if [ -f $out/libexec/gpclient/gp-hip-script-installer ]; then + substituteInPlace $out/share/polkit-1/actions/com.yuezk.gpgui.policy \ + --replace-fail /usr/libexec/gpclient/gp-hip-script-installer $out/libexec/gpclient/gp-hip-script-installer + fi + if [ -f $out/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down ]; then substituteInPlace $out/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down \ --replace-fail /usr/bin/gpclient $out/bin/gpclient @@ -147,6 +152,11 @@ --replace-fail /usr/bin/gpservice $out/bin/gpservice \ --replace-fail /usr/libexec/gpclient/gp-vpnc-script-installer ${prebuiltFiles}/libexec/gpclient/gp-vpnc-script-installer + if [ -f ${prebuiltFiles}/libexec/gpclient/gp-hip-script-installer ]; then + substituteInPlace $out/share/polkit-1/actions/com.yuezk.gpgui.policy \ + --replace-fail /usr/libexec/gpclient/gp-hip-script-installer ${prebuiltFiles}/libexec/gpclient/gp-hip-script-installer + fi + if [ -f $out/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down ]; then substituteInPlace $out/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down \ --replace-fail /usr/bin/gpclient $out/bin/gpclient @@ -225,6 +235,13 @@ --replace-fail /usr/bin/gpservice $out/bin/gpservice \ --replace-fail /usr/bin/gpgui-helper $out/bin/gpgui-helper \ --replace-fail /usr/bin/gpgui $out/bin/gpgui + + if [ -f apps/gpservice/src/hip_source.rs ]; then + substituteInPlace crates/common/src/constants.rs \ + --replace-fail /usr/libexec/gpclient/gp-hip-script-installer $out/libexec/gpclient/gp-hip-script-installer + substituteInPlace apps/gpservice/src/hip_source.rs \ + --replace-fail /usr/libexec/gpclient/gp-hip-runner $out/libexec/gpclient/gp-hip-runner + fi ''; }; @@ -232,6 +249,11 @@ cp -r packaging/files/usr/libexec $out/libexec '' + lib.optionalString pkgs.stdenv.isLinux '' + if [ -f $out/bin/gp-hip-runner ]; then + install -Dm755 $out/bin/gp-hip-runner $out/libexec/gpclient/gp-hip-runner + install -Dm755 $out/bin/gp-hip-script-installer $out/libexec/gpclient/gp-hip-script-installer + fi + # Copy the prebuilt gpgui binary to the output bin directory cp ${gpgui}/gpgui $out/bin/gpgui chmod +x $out/bin/gpgui @@ -300,7 +322,7 @@ while IFS= read -r -d "" env_entry; do env_name="''${env_entry%%=*}" 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) + *[!A-Za-z0-9_]* | [0-9]* | PATH | GP_VPNC_SCRIPT_INSTALLER_BINARY | GP_HIP_SCRIPT_INSTALLER_BINARY | INVOCATION_ID | JOURNAL_STREAM | LISTEN_* | NOTIFY_SOCKET | SYSTEMD_EXEC_PID) continue ;; esac @@ -311,6 +333,7 @@ systemd_run_args+=( "--setenv=PATH=$gui_path" "--setenv=GP_VPNC_SCRIPT_INSTALLER_BINARY=${prebuiltFiles}/libexec/gpclient/gp-vpnc-script-installer" + "--setenv=GP_HIP_SCRIPT_INSTALLER_BINARY=${prebuiltFiles}/libexec/gpclient/gp-hip-script-installer" ) exec ${pkgs.systemd}/bin/systemd-run \ @@ -331,6 +354,7 @@ profile = '' export PATH=/run/wrappers/bin:$PATH export GP_VPNC_SCRIPT_INSTALLER_BINARY='${prebuiltFiles}/libexec/gpclient/gp-vpnc-script-installer' + export GP_HIP_SCRIPT_INSTALLER_BINARY='${prebuiltFiles}/libexec/gpclient/gp-hip-script-installer' ${extraProfile} ''; extraBwrapArgs = [