Merge remote-tracking branch 'origin/main' into feat/auth-callback-handler

This commit is contained in:
Kevin Yue committed 2026-09-01 15:42:25 +08:00
commit e2a64ed7d4
12 files changed
+463 -52

No files matched your search

+90 -16
View File
@@ -20,13 +20,10 @@
nixpkgs,
rust-overlay,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
mkPackageSet =
pkgs:
let
pkgs = (import nixpkgs) {
inherit system;
overlays = [ (import rust-overlay) ];
};
inherit (pkgs) lib;
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
@@ -41,39 +38,67 @@
rustc = toolchain;
};
src = pkgs.fetchzip {
unpackReleaseAsset =
{ name, archive }:
pkgs.runCommand name { nativeBuildInputs = [ pkgs.libarchive ]; } ''
mkdir -p "$out"
bsdtar --extract --file ${archive} --directory "$out" --strip-components 1
'';
sourceArchive = pkgs.fetchurl {
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/globalprotect-openconnect-${version}.tar.gz";
hash = "sha256-T4jze6/25YTsfuQdcuDfz3kX/ooDB1T0hnWsEBu4xMQ=";
hash = "sha256-VFWbF2BfJ9CtXkjQjkgmBGCZnYgB5ZLctqcqUKuhswg=";
};
src = unpackReleaseAsset {
name = "globalprotect-openconnect-${version}-source";
archive = sourceArchive;
};
cpu = pkgs.stdenv.hostPlatform.parsed.cpu.name;
gpguiHashes = {
x86_64 = "sha256-wPLsH/b/ZSo2pA/kU1HUGiQ98k8xSihyxGyf5o6tvyU=";
aarch64 = "sha256-WFyPhGD9fLAVYGeMSrMcZhSdfM99uVmWPrH68O+4BfE=";
x86_64 = "sha256-uVn3hJkKrjKz3mzRamxFu+0rE7OjLtMlT16d14XPcq4=";
aarch64 = "sha256-g4HKQwFAM4YCP+Afew1AhzC1wPrCS8ICw3GeA7KIeFU=";
};
gpgui = pkgs.fetchzip {
gpguiArchive = pkgs.fetchurl {
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/gpgui_${cpu}.bin.tar.xz";
hash = gpguiHashes.${cpu};
};
binaryHashes = {
x86_64 = "sha256-spaKxruu15ro5lir14nAfy8MPXNQhaoCXcG4PDZ9lfM=";
aarch64 = "sha256-iu/zE4B4gjk1I5PQY0m/59ZoJ/k5focT0CxYYlJi7+A=";
gpgui = unpackReleaseAsset {
name = "gpgui-${version}-${cpu}";
archive = gpguiArchive;
};
binaryPackage = pkgs.fetchzip {
binaryHashes = {
x86_64 = "sha256-jgHZC00q+2GnO18/aPGONDCz2CeiF/e1DucefSacv2w=";
aarch64 = "sha256-FDCZN0bmKWKjPiF9wkRaqMUu0PfSVHDUveJVFts25qg=";
};
binaryArchive = pkgs.fetchurl {
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/globalprotect-openconnect_${version}_${cpu}.bin.tar.xz";
hash = binaryHashes.${cpu};
};
binaryPackage = unpackReleaseAsset {
name = "globalprotect-openconnect-${version}-${cpu}-binary";
archive = binaryArchive;
};
linuxRuntimeDependencies = with pkgs; [
glib-networking
libayatana-appindicator
xdg-utils
];
rewriteVpncScriptToolPaths = lib.optionalString pkgs.stdenv.isLinux ''
substituteInPlace $out/libexec/gpclient/vpnc-script \
--replace-fail /usr/bin/resolvectl ${pkgs.systemd}/bin/resolvectl \
--replace-fail /usr/bin/busctl ${pkgs.systemd}/bin/busctl
'';
linuxBuildInputs =
with pkgs;
[
@@ -217,6 +242,7 @@
${installNixosPolkitRule}
''
+ ''
${rewriteVpncScriptToolPaths}
${rewriteSourceInstallPaths}
'';
};
@@ -249,6 +275,8 @@
install -Dm755 ${gpgui}/gpgui $out/bin/gpgui
${rewriteVpncScriptToolPaths}
runHook postInstall
'';
};
@@ -443,6 +471,49 @@
'';
};
in
{
inherit fromSource prebuilt;
};
nixosModule =
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.globalprotect-openconnect;
in
{
options.programs.globalprotect-openconnect = {
enable = lib.mkEnableOption "GlobalProtect-openconnect";
package = lib.mkOption {
type = lib.types.package;
# Use the NixOS module's package set so WebKit and graphics
# dependencies match the rest of the system.
default = (mkPackageSet pkgs).prebuilt;
description = "GlobalProtect-openconnect package to install.";
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
services.ayatana-indicators.enable = lib.mkDefault true;
};
};
in
(flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = (import nixpkgs) {
inherit system;
overlays = [ (import rust-overlay) ];
};
inherit (pkgs) lib;
inherit (mkPackageSet pkgs) fromSource prebuilt;
in
{
# For `nix build`
packages = {
@@ -469,5 +540,8 @@
];
};
}
);
))
// {
nixosModules.default = nixosModule;
};
}