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:
Kevin Yueandgithub-actions[bot] authored and GitHub committed 2026-09-01 09:47:01 +08:00
1 parent 87f91e3c13
commit 8eb4d48887
5 files changed
+186 -28

No files matched your search

+118
View File
@@ -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
+10 -14
View File
@@ -55,21 +55,17 @@ jobs:
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
runner:
- ubuntu-latest
- ubuntu-24.04-arm
nixpkgs:
- locked
- nixos-25.11
- nixos-26.05
- nixpkgs-unstable
exclude:
- runner: ubuntu-24.04-arm
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 }})
runs-on: ${{ matrix.runner }}
steps:
+1
View File
@@ -1,4 +1,5 @@
.idea
.DS_Store
/target
.pnpm-store
.env
+7 -7
View File
@@ -240,16 +240,16 @@ This repository includes a flake for NixOS integration.
#### 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
{
inputs = {
# ... other inputs
globalprotect-openconnect = {
url = "github:yuezk/GlobalProtect-openconnect";
inputs.nixpkgs.follows = "nixpkgs";
};
globalprotect-openconnect.url = "github:yuezk/GlobalProtect-openconnect";
};
outputs = { self, nixpkgs, globalprotect-openconnect, ... }:
@@ -262,11 +262,11 @@ Add the flake input and package to your `flake.nix`:
modules = [
./configuration.nix
globalprotect-openconnect.nixosModules.default
{
services.ayatana-indicators.enable = true;
programs.globalprotect-openconnect.enable = true;
environment.systemPackages = [
globalprotect-openconnect.packages.${system}.default
nixpkgs.legacyPackages.${system}.gnomeExtensions.appindicator
];
}
+50 -7
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);
@@ -399,6 +396,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 = {
@@ -425,5 +465,8 @@
];
};
}
);
))
// {
nixosModules.default = nixosModule;
};
}