mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-17 13:46:27 -05:00
fix: support NixOS prebuilt GUI package
This commit is contained in:
4 files changed
+48
-27
No files matched your search
@@ -348,10 +348,13 @@ jobs:
|
||||
test -x result/bin/gpservice
|
||||
test -x result/bin/gpgui-helper
|
||||
test -x result/bin/gpgui
|
||||
test ! -L result/bin/gpservice
|
||||
head -n1 result/bin/gpclient | grep '^#!'
|
||||
head -n1 result/bin/gpservice | grep '^#!'
|
||||
grep -q '/run/wrappers/bin/pkexec' result/bin/gpclient
|
||||
grep -q 'gpservice_public=.*/bin/gpservice' result/bin/gpclient
|
||||
! grep -q '@gpservice_public@\|\$out/bin/gpservice' result/bin/gpclient
|
||||
grep -q 'exec .*/bin/gpservice' result/bin/gpservice
|
||||
! grep -q '@gpservice_public@\|@gpservice_fhs@\|\$out/bin/gpservice' result/bin/gpclient result/bin/gpservice
|
||||
|
||||
! grep -R '/usr/bin/gp' result/share
|
||||
|
||||
|
||||
@@ -234,8 +234,11 @@ Add the flake input and package to your `flake.nix`:
|
||||
modules = [
|
||||
./configuration.nix
|
||||
{
|
||||
services.ayatana-indicators.enable = true;
|
||||
|
||||
environment.systemPackages = [
|
||||
globalprotect-openconnect.packages.${system}.default
|
||||
nixpkgs.legacyPackages.${system}.gnomeExtensions.appindicator
|
||||
];
|
||||
}
|
||||
];
|
||||
@@ -248,6 +251,13 @@ Apply:
|
||||
|
||||
```bash
|
||||
sudo nixos-rebuild switch
|
||||
loginctl terminate-user "$USER"
|
||||
```
|
||||
|
||||
After logging back in to GNOME, enable AppIndicator support if needed:
|
||||
|
||||
```bash
|
||||
gnome-extensions enable [email protected]
|
||||
```
|
||||
|
||||
### Official Docker Image
|
||||
|
||||
@@ -33,41 +33,28 @@ mod platform {
|
||||
let session_env = collect(user_id);
|
||||
|
||||
for key in DESKTOP_SESSION_ENV {
|
||||
if let Some(value) = env_value(key).or_else(|| session_env.get(*key).cloned()) {
|
||||
if let Some(value) = desktop_env_value(&session_env, key) {
|
||||
command.env(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
let runtime_dir = env_value("XDG_RUNTIME_DIR")
|
||||
.or_else(|| session_env.get("XDG_RUNTIME_DIR").cloned())
|
||||
.unwrap_or_else(|| format!("/run/user/{user_id}"));
|
||||
let runtime_dir =
|
||||
desktop_env_value(&session_env, "XDG_RUNTIME_DIR").unwrap_or_else(|| format!("/run/user/{user_id}"));
|
||||
command.env("XDG_RUNTIME_DIR", &runtime_dir);
|
||||
|
||||
if env_value("DBUS_SESSION_BUS_ADDRESS")
|
||||
.or_else(|| session_env.get("DBUS_SESSION_BUS_ADDRESS").cloned())
|
||||
.is_none()
|
||||
{
|
||||
if desktop_env_value(&session_env, "DBUS_SESSION_BUS_ADDRESS").is_none() {
|
||||
command.env("DBUS_SESSION_BUS_ADDRESS", format!("unix:path={runtime_dir}/bus"));
|
||||
}
|
||||
|
||||
if env_value("XDG_DATA_HOME")
|
||||
.or_else(|| session_env.get("XDG_DATA_HOME").cloned())
|
||||
.is_none()
|
||||
{
|
||||
if desktop_env_value(&session_env, "XDG_DATA_HOME").is_none() {
|
||||
command.env("XDG_DATA_HOME", home_dir.join(".local/share"));
|
||||
}
|
||||
|
||||
if env_value("XDG_CONFIG_HOME")
|
||||
.or_else(|| session_env.get("XDG_CONFIG_HOME").cloned())
|
||||
.is_none()
|
||||
{
|
||||
if desktop_env_value(&session_env, "XDG_CONFIG_HOME").is_none() {
|
||||
command.env("XDG_CONFIG_HOME", home_dir.join(".config"));
|
||||
}
|
||||
|
||||
if env_value("XDG_DATA_DIRS")
|
||||
.or_else(|| session_env.get("XDG_DATA_DIRS").cloned())
|
||||
.is_none()
|
||||
{
|
||||
if desktop_env_value(&session_env, "XDG_DATA_DIRS").is_none() {
|
||||
command.env("XDG_DATA_DIRS", default_xdg_data_dirs());
|
||||
}
|
||||
}
|
||||
@@ -160,6 +147,10 @@ mod platform {
|
||||
non_empty(env::var(key).ok())
|
||||
}
|
||||
|
||||
fn desktop_env_value(session_env: &HashMap<String, String>, key: &str) -> Option<String> {
|
||||
session_env.get(key).cloned().or_else(|| env_value(key))
|
||||
}
|
||||
|
||||
fn non_empty(value: Option<String>) -> Option<String> {
|
||||
value.filter(|value| !value.trim().is_empty())
|
||||
}
|
||||
@@ -203,6 +194,16 @@ mod platform {
|
||||
assert_eq!(non_empty(Some(" ".to_string())), None);
|
||||
assert_eq!(non_empty(Some("value".to_string())), Some("value".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn desktop_env_value_prefers_collected_user_session() {
|
||||
let env = HashMap::from([("XDG_DATA_DIRS".to_string(), "/run/current-system/sw/share".to_string())]);
|
||||
|
||||
assert_eq!(
|
||||
desktop_env_value(&env, "XDG_DATA_DIRS"),
|
||||
Some("/run/current-system/sw/share".to_string())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
linuxRuntimeDependencies = with pkgs; [
|
||||
glib-networking
|
||||
libappindicator-gtk3
|
||||
libayatana-appindicator
|
||||
];
|
||||
|
||||
linuxBuildInputs =
|
||||
@@ -85,7 +85,7 @@
|
||||
glib-networking
|
||||
openssl
|
||||
libsecret
|
||||
libappindicator-gtk3
|
||||
libayatana-appindicator
|
||||
];
|
||||
|
||||
rewriteSourceInstallPaths = ''
|
||||
@@ -207,9 +207,7 @@
|
||||
name = binaryName;
|
||||
targetPkgs =
|
||||
pkgs:
|
||||
[
|
||||
prebuiltFiles
|
||||
]
|
||||
[ prebuiltFiles ]
|
||||
++ linuxBuildInputs
|
||||
++ linuxRuntimeDependencies;
|
||||
runScript = "/usr/bin/${binaryName}";
|
||||
@@ -307,7 +305,16 @@
|
||||
substituteInPlace $out/bin/gpclient \
|
||||
--replace-fail '@gpservice_public@' "$out/bin/gpservice"
|
||||
chmod +x $out/bin/gpclient
|
||||
ln -s ${prebuiltCommands.gpservice}/bin/gpservice $out/bin/gpservice
|
||||
|
||||
cat > $out/bin/gpservice <<'EOF'
|
||||
#!${pkgs.runtimeShell}
|
||||
set -eu
|
||||
exec '@gpservice_fhs@' "$@"
|
||||
EOF
|
||||
substituteInPlace $out/bin/gpservice \
|
||||
--replace-fail '@gpservice_fhs@' '${prebuiltCommands.gpservice}/bin/gpservice'
|
||||
chmod +x $out/bin/gpservice
|
||||
|
||||
ln -s ${prebuiltCommands.gpauth}/bin/gpauth $out/bin/gpauth
|
||||
ln -s ${prebuiltCommands.gpgui}/bin/gpgui $out/bin/gpgui
|
||||
ln -s ${prebuiltCommands."gpgui-helper"}/bin/gpgui-helper $out/bin/gpgui-helper
|
||||
|
||||
Reference in new issue
Block a user