mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-24 15:56:13 -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/gpservice
|
||||||
test -x result/bin/gpgui-helper
|
test -x result/bin/gpgui-helper
|
||||||
test -x result/bin/gpgui
|
test -x result/bin/gpgui
|
||||||
|
test ! -L result/bin/gpservice
|
||||||
head -n1 result/bin/gpclient | grep '^#!'
|
head -n1 result/bin/gpclient | grep '^#!'
|
||||||
|
head -n1 result/bin/gpservice | grep '^#!'
|
||||||
grep -q '/run/wrappers/bin/pkexec' result/bin/gpclient
|
grep -q '/run/wrappers/bin/pkexec' result/bin/gpclient
|
||||||
grep -q 'gpservice_public=.*/bin/gpservice' 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
|
! grep -R '/usr/bin/gp' result/share
|
||||||
|
|
||||||
|
|||||||
@@ -234,8 +234,11 @@ Add the flake input and package to your `flake.nix`:
|
|||||||
modules = [
|
modules = [
|
||||||
./configuration.nix
|
./configuration.nix
|
||||||
{
|
{
|
||||||
|
services.ayatana-indicators.enable = true;
|
||||||
|
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
globalprotect-openconnect.packages.${system}.default
|
globalprotect-openconnect.packages.${system}.default
|
||||||
|
nixpkgs.legacyPackages.${system}.gnomeExtensions.appindicator
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@@ -248,6 +251,13 @@ Apply:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo nixos-rebuild switch
|
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
|
### Official Docker Image
|
||||||
|
|||||||
@@ -33,41 +33,28 @@ mod platform {
|
|||||||
let session_env = collect(user_id);
|
let session_env = collect(user_id);
|
||||||
|
|
||||||
for key in DESKTOP_SESSION_ENV {
|
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);
|
command.env(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let runtime_dir = env_value("XDG_RUNTIME_DIR")
|
let runtime_dir =
|
||||||
.or_else(|| session_env.get("XDG_RUNTIME_DIR").cloned())
|
desktop_env_value(&session_env, "XDG_RUNTIME_DIR").unwrap_or_else(|| format!("/run/user/{user_id}"));
|
||||||
.unwrap_or_else(|| format!("/run/user/{user_id}"));
|
|
||||||
command.env("XDG_RUNTIME_DIR", &runtime_dir);
|
command.env("XDG_RUNTIME_DIR", &runtime_dir);
|
||||||
|
|
||||||
if env_value("DBUS_SESSION_BUS_ADDRESS")
|
if desktop_env_value(&session_env, "DBUS_SESSION_BUS_ADDRESS").is_none() {
|
||||||
.or_else(|| session_env.get("DBUS_SESSION_BUS_ADDRESS").cloned())
|
|
||||||
.is_none()
|
|
||||||
{
|
|
||||||
command.env("DBUS_SESSION_BUS_ADDRESS", format!("unix:path={runtime_dir}/bus"));
|
command.env("DBUS_SESSION_BUS_ADDRESS", format!("unix:path={runtime_dir}/bus"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if env_value("XDG_DATA_HOME")
|
if desktop_env_value(&session_env, "XDG_DATA_HOME").is_none() {
|
||||||
.or_else(|| session_env.get("XDG_DATA_HOME").cloned())
|
|
||||||
.is_none()
|
|
||||||
{
|
|
||||||
command.env("XDG_DATA_HOME", home_dir.join(".local/share"));
|
command.env("XDG_DATA_HOME", home_dir.join(".local/share"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if env_value("XDG_CONFIG_HOME")
|
if desktop_env_value(&session_env, "XDG_CONFIG_HOME").is_none() {
|
||||||
.or_else(|| session_env.get("XDG_CONFIG_HOME").cloned())
|
|
||||||
.is_none()
|
|
||||||
{
|
|
||||||
command.env("XDG_CONFIG_HOME", home_dir.join(".config"));
|
command.env("XDG_CONFIG_HOME", home_dir.join(".config"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if env_value("XDG_DATA_DIRS")
|
if desktop_env_value(&session_env, "XDG_DATA_DIRS").is_none() {
|
||||||
.or_else(|| session_env.get("XDG_DATA_DIRS").cloned())
|
|
||||||
.is_none()
|
|
||||||
{
|
|
||||||
command.env("XDG_DATA_DIRS", default_xdg_data_dirs());
|
command.env("XDG_DATA_DIRS", default_xdg_data_dirs());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,6 +147,10 @@ mod platform {
|
|||||||
non_empty(env::var(key).ok())
|
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> {
|
fn non_empty(value: Option<String>) -> Option<String> {
|
||||||
value.filter(|value| !value.trim().is_empty())
|
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(" ".to_string())), None);
|
||||||
assert_eq!(non_empty(Some("value".to_string())), Some("value".to_string()));
|
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; [
|
linuxRuntimeDependencies = with pkgs; [
|
||||||
glib-networking
|
glib-networking
|
||||||
libappindicator-gtk3
|
libayatana-appindicator
|
||||||
];
|
];
|
||||||
|
|
||||||
linuxBuildInputs =
|
linuxBuildInputs =
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
glib-networking
|
glib-networking
|
||||||
openssl
|
openssl
|
||||||
libsecret
|
libsecret
|
||||||
libappindicator-gtk3
|
libayatana-appindicator
|
||||||
];
|
];
|
||||||
|
|
||||||
rewriteSourceInstallPaths = ''
|
rewriteSourceInstallPaths = ''
|
||||||
@@ -207,9 +207,7 @@
|
|||||||
name = binaryName;
|
name = binaryName;
|
||||||
targetPkgs =
|
targetPkgs =
|
||||||
pkgs:
|
pkgs:
|
||||||
[
|
[ prebuiltFiles ]
|
||||||
prebuiltFiles
|
|
||||||
]
|
|
||||||
++ linuxBuildInputs
|
++ linuxBuildInputs
|
||||||
++ linuxRuntimeDependencies;
|
++ linuxRuntimeDependencies;
|
||||||
runScript = "/usr/bin/${binaryName}";
|
runScript = "/usr/bin/${binaryName}";
|
||||||
@@ -307,7 +305,16 @@
|
|||||||
substituteInPlace $out/bin/gpclient \
|
substituteInPlace $out/bin/gpclient \
|
||||||
--replace-fail '@gpservice_public@' "$out/bin/gpservice"
|
--replace-fail '@gpservice_public@' "$out/bin/gpservice"
|
||||||
chmod +x $out/bin/gpclient
|
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.gpauth}/bin/gpauth $out/bin/gpauth
|
||||||
ln -s ${prebuiltCommands.gpgui}/bin/gpgui $out/bin/gpgui
|
ln -s ${prebuiltCommands.gpgui}/bin/gpgui $out/bin/gpgui
|
||||||
ln -s ${prebuiltCommands."gpgui-helper"}/bin/gpgui-helper $out/bin/gpgui-helper
|
ln -s ${prebuiltCommands."gpgui-helper"}/bin/gpgui-helper $out/bin/gpgui-helper
|
||||||
|
|||||||
Reference in new issue
Block a user