From fbf0a5a1a078c78c6fdf8ee8a13209c1fd71af3e Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 5 Nov 2026 06:49:22 -0800 Subject: [PATCH 1/3] chore(quest): claim quest/m0/ci/nix-builder-userns.md Quest-Claim: 64c35e06d0481e5e From 1e4f331a9cffa767e98f8a802a4a320a7bc5ad97 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 5 Nov 2026 07:02:39 -0800 Subject: [PATCH 2/3] fix(ci): allow desktop Nix builders to map user namespaces The desktop host loads an AppArmor profile that grants user namespaces only to the Nix store's util-linux unshare. check flake builds the runner image, so this quest is finished. Co-authored-by: Grok 4.7 --- quest/m0/ci/README.md | 1 - quest/m0/ci/nix-builder-userns.md | 30 ------------------------------ 2 files changed, 31 deletions(-) delete mode 100644 quest/m0/ci/nix-builder-userns.md diff --git a/quest/m0/ci/README.md b/quest/m0/ci/README.md index 8f7bf1994ee..95342389296 100644 --- a/quest/m0/ci/README.md +++ b/quest/m0/ci/README.md @@ -187,4 +187,3 @@ The historical samples locate candidates; they are not controlled benchmarks. - [A release merge opens no stale release PR](/quest/m0/ci/release-pr-after-release.md) - `just rs release` publishes before it proposes, so a merged release isn't re-proposed - [Build two queue entries at once if it helps](/quest/m0/ci/queue-concurrency.md) - a measured trial of `maximumEntriesToBuild: 2` against the serial lane's burst latency - [macOS CI runs kio's tests](/quest/m0/ci/macos-kio.md) - `just rs macos-test` includes kio -- [The desktop host's Nix builders may map user namespaces](/quest/m0/ci/nix-builder-userns.md) - agents' local `just ci` builds the runner image instead of failing `check flake` diff --git a/quest/m0/ci/nix-builder-userns.md b/quest/m0/ci/nix-builder-userns.md deleted file mode 100644 index ffb22d075a6..00000000000 --- a/quest/m0/ci/nix-builder-userns.md +++ /dev/null @@ -1,30 +0,0 @@ -# [S] The desktop host's Nix builders may map user namespaces - -## Goal - -On the desktop host, where agents run their local gates, `just ci` builds the -flake's runner image instead of failing `check flake`, and `just check` runs -it instead of skipping. - -## Plan - -Decided 2026-11-05 (maintainer, follow-up seen in -[moq-dev/moq#7918](https://github.com/moq-dev/moq/pull/7918), -[moq-dev/moq#7684](https://github.com/moq-dev/moq/pull/7684), -[moq-dev/moq#7858](https://github.com/moq-dev/moq/pull/7858), and -[moq-dev/moq#7883](https://github.com/moq-dev/moq/pull/7883)): ✅ m0. - -Each of those gates failed `check flake` while building `github-runner`, with -`unshare: write failed /proc/self/uid_map: Operation not permitted`. `just ci` -sets `CI_STRICT`, so the check fails there; without it, -`nix/runner/userns-probe.nix` and `sh/dispatch.sh` detect the refusal and skip, -which is why [moq-dev/moq#7763](https://github.com/moq-dev/moq/pull/7763) -retired the earlier quest. This quest fixes the host instead, so nothing fails -or skips. - -As of 2026-11-05 the probe fails on the desktop host (Ubuntu 26.04, where -`kernel.apparmor_restrict_unprivileged_userns = 1` and even a plain -`unshare --map-root-user true` is refused) and passes on `nixos`. Lift -AppArmor's restriction for Nix builds there, persistently and as narrowly as -works, apply it when no gate is running, and check that the probe succeeds and -`just ci` passes `check flake`. From df8fba37b5004e14e4fd082849834b6502ea99fe Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 5 Nov 2026 07:07:35 -0800 Subject: [PATCH 3/3] fix(ci): install the desktop userns profile from the repo just gh runner-userns copies the util-linux unshare profile into /etc/apparmor.d and loads it. A store-path glob keeps the next nixpkgs pin covered, and /usr/bin/unshare stays denied. Co-authored-by: Grok 4.7 --- .github/justfile | 11 +++++++++++ nix/runner/README.md | 7 +++++++ nix/runner/nix-builder-unshare | 13 +++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 nix/runner/nix-builder-unshare diff --git a/.github/justfile b/.github/justfile index a532a083855..cb99d1cf017 100644 --- a/.github/justfile +++ b/.github/justfile @@ -17,6 +17,17 @@ runner-vm-ci: trap 'sudo apparmor_parser --remove "$profile"' EXIT just gh runner-vm +# Install the persistent host profile that lets Nix store unshare map user namespaces. +runner-userns: + #!/usr/bin/env bash + set -euo pipefail + if [[ "${GITHUB_ACTIONS:-}" == true ]]; then + echo "runner-userns is persistent host policy; a hosted runner uses runner-vm-ci" >&2 + exit 1 + fi + sudo install -m 0644 nix/runner/nix-builder-unshare /etc/apparmor.d/nix-builder-unshare + sudo apparmor_parser --replace /etc/apparmor.d/nix-builder-unshare + # Build and test the persistent NixOS runner VM on x86_64 Linux. runner-vm: bash sh/local.sh nix build --no-link .#checks.x86_64-linux.github-runner-vm .#checks.x86_64-linux.github-runner-vm-image .#checks.x86_64-linux.github-runner-vm-config --print-build-logs diff --git a/nix/runner/README.md b/nix/runner/README.md index 1a20ce2dfce..0ab20e780a3 100644 --- a/nix/runner/README.md +++ b/nix/runner/README.md @@ -144,6 +144,13 @@ refuses local and self-hosted runners, and unloads the profile on exit, including build failure. `just gh runner-vm` does not change host policy; its build host must already support rootless user namespaces. +Ubuntu denies that map when `kernel.apparmor_restrict_unprivileged_userns` is +set, unless the binary has a profile. `just gh runner-userns` installs +`nix/runner/nix-builder-unshare` into `/etc/apparmor.d/` and loads it. The +profile allows user namespaces only for `/nix/store/*util-linux*/bin/unshare`, +so a nixpkgs bump still matches, and `/usr/bin/unshare` stays denied. AppArmor +stays enabled. Run it again only after the host profile is removed. + `just gh runner-vm` builds a guest image and runs NixOS integration tests for startup without carrier, public egress for multiple guests, private-network and sibling-guest isolation including spoofed established replies, compatible host NAT diff --git a/nix/runner/nix-builder-unshare b/nix/runner/nix-builder-unshare new file mode 100644 index 00000000000..145314b743c --- /dev/null +++ b/nix/runner/nix-builder-unshare @@ -0,0 +1,13 @@ +# Nix image builds run the store copy of util-linux unshare +# (`unshare --map-root-user fakeroot systemd-repart`). Ubuntu denies the +# uid map unless that binary has a userns profile. /usr/bin/unshare stays denied. +abi , +include + +profile nix-builder-unshare /nix/store/*util-linux*/bin/unshare flags=(unconfined) { + userns, + @{exec_path} mr, + + # Site-specific additions and overrides. See local/README for details. + include if exists +}