[PR #186] Add a Nix flake and opt-in NixOS module #184

Open
opened 2026-10-27 06:17:00 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Zagitta/gpu-unlock/pull/186
Author: @bearice
Created: 10/26/2026
Status: 🔄 Open

Base: main ← Head: nix-flake


📝 Commits (6)

  • b48a9ae Add reusable Nix flake and opt-in NixOS module
  • d80ef28 docs: shorten Nix setup instructions
  • bb33197 Fix NixOS unstable initrd and kernel-module installation compatibility
  • 55d6e71 Move Nix support under packaging and adapt to upstream 1.1.0
  • 5f0a572 Address NixOS review feedback after rebase onto 2.0
  • b17ebbe Warn when NixOS cannot re-unlock after suspend; keep -Werror in checks

📊 Changes

10 files changed (+514 additions, -0 deletions)

View changed files

📝 .gitattributes (+2 -0)
➕ .github/workflows/nix.yml (+37 -0)
📝 README.md (+2 -0)
➕ flake.lock (+27 -0)
➕ flake.nix (+66 -0)
➕ packaging/nix/README.md (+73 -0)
➕ packaging/nix/check-initrd.py (+82 -0)
➕ packaging/nix/checks.nix (+54 -0)
➕ packaging/nix/module.nix (+75 -0)
➕ packaging/nix/package.nix (+96 -0)

📄 Description

NixOS users can import the module, select explicit PCI targets, and build a boot generation that runs the unlock before NVIDIA binds the device. The module builds against the consumer's boot.kernelPackages and supports systemd and scripted initrds where available.

This adds:

  • A root flake with kernel-module and firmware packages, a development shell, and a formatter. Nix implementation and documentation live in packaging/nix/, alongside the other distribution packaging.
  • SHA-256-pinned NVIDIA source and installer downloads, using upstream's firmware extraction targets and standard Kbuild module installation, including nixpkgs signing artifacts.
  • Opt-in hardware.nvidia.gpuUnlock options for targets, package overrides, and resume handling. Both the module and resume handling default to disabled.
  • CI and integration checks for opt-in behavior, target validation, kernel ABI, firmware contents, and initrd loading order. The root README adds only an installation link.

Validation:

  • nix flake check passed on x86_64-linux with the locked NixOS 26.05 nixpkgs and unstable (3ec636362e18), including module compilation, firmware extraction, and inspection of the built initrds. Scripted initrd checks run only where supported.
  • Installed and boot-tested upstream 1.1.0 with this flake at 920e57a on an RTX 3080 Laptop 16GB (10de:249c), NixOS 26.05, Linux 6.18.57, and NVIDIA Open 595.71.05. The loaded module matched the flake build; unlock completed before NVIDIA loaded; post-FLR selectors remained ss0=0x88888888, ss1=0x8; handoff returned 0 with no retained pages. NVIDIA rebound normally, a 4096-element CUDA vector-add matched CPU results exactly, and a Strata chat request succeeded. No NVIDIA Xid or unlock errors were observed.
  • Nix CI and existing distribution CI passed for 920e57a.

Kernel sources and existing distribution installers are unchanged. Build checks require no GPU and do not validate hardware performance or suspend/resume behavior.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Zagitta/gpu-unlock/pull/186 **Author:** [@bearice](https://github.com/bearice) **Created:** 10/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `nix-flake` --- ### 📝 Commits (6) - [`b48a9ae`](https://github.com/Zagitta/gpu-unlock/commit/b48a9ae43aa909a2c7764b51e1aede0ff4c9802b) Add reusable Nix flake and opt-in NixOS module - [`d80ef28`](https://github.com/Zagitta/gpu-unlock/commit/d80ef289ffdf861ec183067fd01eca70c356e640) docs: shorten Nix setup instructions - [`bb33197`](https://github.com/Zagitta/gpu-unlock/commit/bb331978d4200beec27637bfdc1dec9fcd7e6355) Fix NixOS unstable initrd and kernel-module installation compatibility - [`55d6e71`](https://github.com/Zagitta/gpu-unlock/commit/55d6e71bf2fd9a800a2cebbdd71b302c1d35b494) Move Nix support under packaging and adapt to upstream 1.1.0 - [`5f0a572`](https://github.com/Zagitta/gpu-unlock/commit/5f0a572586af161e244fb469fe27d3163aaa2a82) Address NixOS review feedback after rebase onto 2.0 - [`b17ebbe`](https://github.com/Zagitta/gpu-unlock/commit/b17ebbeec5ca3caa004e4261a763a6e122bb4439) Warn when NixOS cannot re-unlock after suspend; keep -Werror in checks ### 📊 Changes **10 files changed** (+514 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `.gitattributes` (+2 -0) ➕ `.github/workflows/nix.yml` (+37 -0) 📝 `README.md` (+2 -0) ➕ `flake.lock` (+27 -0) ➕ `flake.nix` (+66 -0) ➕ `packaging/nix/README.md` (+73 -0) ➕ `packaging/nix/check-initrd.py` (+82 -0) ➕ `packaging/nix/checks.nix` (+54 -0) ➕ `packaging/nix/module.nix` (+75 -0) ➕ `packaging/nix/package.nix` (+96 -0) </details> ### 📄 Description NixOS users can import the module, select explicit PCI targets, and build a boot generation that runs the unlock before NVIDIA binds the device. The module builds against the consumer's `boot.kernelPackages` and supports systemd and scripted initrds where available. This adds: - A root flake with kernel-module and firmware packages, a development shell, and a formatter. Nix implementation and documentation live in `packaging/nix/`, alongside the other distribution packaging. - SHA-256-pinned NVIDIA source and installer downloads, using upstream's firmware extraction targets and standard Kbuild module installation, including nixpkgs signing artifacts. - Opt-in `hardware.nvidia.gpuUnlock` options for targets, package overrides, and resume handling. Both the module and resume handling default to disabled. - CI and integration checks for opt-in behavior, target validation, kernel ABI, firmware contents, and initrd loading order. The root README adds only an installation link. Validation: - `nix flake check` passed on `x86_64-linux` with the locked NixOS 26.05 nixpkgs and unstable (`3ec636362e18`), including module compilation, firmware extraction, and inspection of the built initrds. Scripted initrd checks run only where supported. - Installed and boot-tested upstream 1.1.0 with this flake at `920e57a` on an RTX 3080 Laptop 16GB (10de:249c), NixOS 26.05, Linux 6.18.57, and NVIDIA Open 595.71.05. The loaded module matched the flake build; unlock completed before NVIDIA loaded; post-FLR selectors remained `ss0=0x88888888`, `ss1=0x8`; handoff returned 0 with no retained pages. NVIDIA rebound normally, a 4096-element CUDA vector-add matched CPU results exactly, and a Strata chat request succeeded. No NVIDIA Xid or unlock errors were observed. - [Nix CI](https://github.com/bearice/gpu-unlock/actions/runs/40454878767) and [existing distribution CI](https://github.com/bearice/gpu-unlock/actions/runs/40454878663) passed for `920e57a`. Kernel sources and existing distribution installers are unchanged. Build checks require no GPU and do not validate hardware performance or suspend/resume behavior. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Zagitta/gpu-unlock#184
No description provided.