mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 06:26:14 -05:00
feat: add host-aligned NixOS module (#652)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
87f91e3c13
commit
8eb4d48887
5 files changed
+186
-28
No files matched your search
@@ -0,0 +1,118 @@
|
|||||||
|
name: Nix
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- "flake.nix"
|
||||||
|
- "flake.lock"
|
||||||
|
- "nix/**"
|
||||||
|
- ".github/workflows/nix.yaml"
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- "flake.nix"
|
||||||
|
- "flake.lock"
|
||||||
|
- "nix/**"
|
||||||
|
- ".github/workflows/nix.yaml"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
standalone-package:
|
||||||
|
name: standalone-package (${{ matrix.platform.system }})
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- runner: ubuntu-latest
|
||||||
|
system: x86_64-linux
|
||||||
|
- runner: ubuntu-24.04-arm
|
||||||
|
system: aarch64-linux
|
||||||
|
runs-on: ${{ matrix.platform.runner }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout GlobalProtect-openconnect
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Install Nix
|
||||||
|
uses: cachix/install-nix-action@v31
|
||||||
|
|
||||||
|
- name: Build standalone prebuilt package
|
||||||
|
run: |
|
||||||
|
nix build .#prebuilt \
|
||||||
|
--extra-experimental-features "nix-command flakes" \
|
||||||
|
--print-build-logs
|
||||||
|
|
||||||
|
- name: Inspect prebuilt package
|
||||||
|
run: |
|
||||||
|
test -x result/bin/gpclient
|
||||||
|
test -x result/bin/gpauth
|
||||||
|
test -x result/bin/gpservice
|
||||||
|
test -x result/bin/gpgui-helper
|
||||||
|
test -x result/bin/gpgui
|
||||||
|
|
||||||
|
nixos-module:
|
||||||
|
name: nixos-module (${{ matrix.platform.system }}, ${{ matrix.nixpkgs }})
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- runner: ubuntu-latest
|
||||||
|
system: x86_64-linux
|
||||||
|
- runner: ubuntu-24.04-arm
|
||||||
|
system: aarch64-linux
|
||||||
|
nixpkgs:
|
||||||
|
- nixos-25.11
|
||||||
|
- nixos-26.05
|
||||||
|
- nixpkgs-unstable
|
||||||
|
runs-on: ${{ matrix.platform.runner }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout GlobalProtect-openconnect
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Install Nix
|
||||||
|
uses: cachix/install-nix-action@v31
|
||||||
|
|
||||||
|
- name: Build package through host NixOS module
|
||||||
|
env:
|
||||||
|
NIXPKGS_URL: github:NixOS/nixpkgs/${{ matrix.nixpkgs }}
|
||||||
|
NIX_SYSTEM: ${{ matrix.platform.system }}
|
||||||
|
run: |
|
||||||
|
nix build \
|
||||||
|
--impure \
|
||||||
|
--extra-experimental-features "nix-command flakes" \
|
||||||
|
--print-build-logs \
|
||||||
|
--expr '
|
||||||
|
let
|
||||||
|
gp = builtins.getFlake (toString ./.);
|
||||||
|
hostNixpkgs =
|
||||||
|
builtins.getFlake (builtins.getEnv "NIXPKGS_URL");
|
||||||
|
|
||||||
|
hostSystem = hostNixpkgs.lib.nixosSystem {
|
||||||
|
system = builtins.getEnv "NIX_SYSTEM";
|
||||||
|
modules = [
|
||||||
|
gp.nixosModules.default
|
||||||
|
{
|
||||||
|
programs.globalprotect-openconnect.enable = true;
|
||||||
|
system.stateVersion = "25.11";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
package =
|
||||||
|
hostSystem.config.programs.globalprotect-openconnect.package;
|
||||||
|
in
|
||||||
|
assert builtins.elem package
|
||||||
|
hostSystem.config.environment.systemPackages;
|
||||||
|
assert hostSystem.config.services.ayatana-indicators.enable;
|
||||||
|
package
|
||||||
|
'
|
||||||
|
|
||||||
|
- name: Inspect module package
|
||||||
|
run: |
|
||||||
|
test -x result/bin/gpclient
|
||||||
|
test -x result/bin/gpauth
|
||||||
|
test -x result/bin/gpservice
|
||||||
|
test -x result/bin/gpgui-helper
|
||||||
|
test -x result/bin/gpgui
|
||||||
@@ -55,21 +55,17 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
runner:
|
||||||
- runner: ubuntu-latest
|
- ubuntu-latest
|
||||||
|
- ubuntu-24.04-arm
|
||||||
|
nixpkgs:
|
||||||
|
- locked
|
||||||
|
- nixos-25.11
|
||||||
|
- nixos-26.05
|
||||||
|
- nixpkgs-unstable
|
||||||
|
exclude:
|
||||||
|
- runner: ubuntu-24.04-arm
|
||||||
nixpkgs: locked
|
nixpkgs: locked
|
||||||
- runner: ubuntu-latest
|
|
||||||
nixpkgs: nixos-25.11
|
|
||||||
- runner: ubuntu-latest
|
|
||||||
nixpkgs: nixos-26.05
|
|
||||||
- runner: ubuntu-latest
|
|
||||||
nixpkgs: nixpkgs-unstable
|
|
||||||
- runner: ubuntu-24.04-arm
|
|
||||||
nixpkgs: nixos-25.11
|
|
||||||
- runner: ubuntu-24.04-arm
|
|
||||||
nixpkgs: nixos-26.05
|
|
||||||
- runner: ubuntu-24.04-arm
|
|
||||||
nixpkgs: nixpkgs-unstable
|
|
||||||
name: validate-nix-prebuilt (${{ matrix.nixpkgs }}, ${{ matrix.runner }})
|
name: validate-nix-prebuilt (${{ matrix.nixpkgs }}, ${{ matrix.runner }})
|
||||||
runs-on: ${{ matrix.runner }}
|
runs-on: ${{ matrix.runner }}
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
.idea
|
.idea
|
||||||
|
.DS_Store
|
||||||
/target
|
/target
|
||||||
.pnpm-store
|
.pnpm-store
|
||||||
.env
|
.env
|
||||||
|
|||||||
@@ -240,16 +240,16 @@ This repository includes a flake for NixOS integration.
|
|||||||
|
|
||||||
#### Installation Steps
|
#### Installation Steps
|
||||||
|
|
||||||
Add the flake input and package to your `flake.nix`:
|
Add the flake input and NixOS module to your `flake.nix`:
|
||||||
|
|
||||||
|
The module builds the package with your NixOS configuration's `pkgs`, so the
|
||||||
|
GlobalProtect GUI and the system use the same Nixpkgs dependency versions.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
# ... other inputs
|
# ... other inputs
|
||||||
globalprotect-openconnect = {
|
globalprotect-openconnect.url = "github:yuezk/GlobalProtect-openconnect";
|
||||||
url = "github:yuezk/GlobalProtect-openconnect";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, globalprotect-openconnect, ... }:
|
outputs = { self, nixpkgs, globalprotect-openconnect, ... }:
|
||||||
@@ -262,11 +262,11 @@ Add the flake input and package to your `flake.nix`:
|
|||||||
|
|
||||||
modules = [
|
modules = [
|
||||||
./configuration.nix
|
./configuration.nix
|
||||||
|
globalprotect-openconnect.nixosModules.default
|
||||||
{
|
{
|
||||||
services.ayatana-indicators.enable = true;
|
programs.globalprotect-openconnect.enable = true;
|
||||||
|
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
globalprotect-openconnect.packages.${system}.default
|
|
||||||
nixpkgs.legacyPackages.${system}.gnomeExtensions.appindicator
|
nixpkgs.legacyPackages.${system}.gnomeExtensions.appindicator
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,13 +20,10 @@
|
|||||||
nixpkgs,
|
nixpkgs,
|
||||||
rust-overlay,
|
rust-overlay,
|
||||||
}:
|
}:
|
||||||
flake-utils.lib.eachDefaultSystem (
|
let
|
||||||
system:
|
mkPackageSet =
|
||||||
|
pkgs:
|
||||||
let
|
let
|
||||||
pkgs = (import nixpkgs) {
|
|
||||||
inherit system;
|
|
||||||
overlays = [ (import rust-overlay) ];
|
|
||||||
};
|
|
||||||
inherit (pkgs) lib;
|
inherit (pkgs) lib;
|
||||||
|
|
||||||
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
||||||
@@ -399,6 +396,49 @@
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
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`
|
# For `nix build`
|
||||||
packages = {
|
packages = {
|
||||||
@@ -425,5 +465,8 @@
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
))
|
||||||
|
// {
|
||||||
|
nixosModules.default = nixosModule;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user