Skip to content

fix(image): set empty build-users-group in baked nix.conf - #750

Merged
c-vigo merged 1 commit into
feature/625-nix-claude-migrationfrom
bugfix/749-nixbld-group
Jun 29, 2026
Merged

c-vigo merged 1 commit into
feature/625-nix-claude-migrationfrom
bugfix/749-nixbld-group

Conversation

@c-vigo

@c-vigo c-vigo commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Closes #749. Extends #739: the baked nix.conf enabled nix-command/flakes but the in-image root/single-user/daemonless nix has no nixbld group, so on-demand nix shell/nix develop needing a local build (not pure cache substitution — e.g. a rust-overlay toolchain) aborted. Adds build-users-group = (empty). Verified in-image: a local derivation build now succeeds. New test_nix_conf_disables_build_users_group asserts the setting.

The in-image nix runs as root, single-user, daemonless (no nixbld group), so on-demand 'nix shell'/'nix develop' needing a local build aborted with "the group 'nixbld' does not exist" (e.g. a rust-overlay toolchain). Bake 'build-users-group =' (empty) so root builds directly. Extends #739.

Refs: #749
@c-vigo
c-vigo merged commit 30a20d2 into feature/625-nix-claude-migration Jun 29, 2026
10 checks passed
@c-vigo
c-vigo deleted the bugfix/749-nixbld-group branch June 29, 2026 14:14
c-vigo added a commit that referenced this pull request Jun 30, 2026
…onfig (#782)

## Problem

`accept-flake-config = true` was baked into the image's
`/etc/nix/nix.conf`. That made any in-container `nix run
github:attacker/flake` silently accept that flake's
`substituters`/`trusted-public-keys` — the textbook Nix
cache-redirection supply-chain attack (PR #670 roadmap thread A).

## Fix

- **Remove** `accept-flake-config = true` from the baked nix.conf.
- **Bake explicit** `substituters` + `trusted-public-keys` so normal
builds still hit the caches, while a foreign flake's `nixConfig` now
requires a per-invocation `--accept-flake-config`.
- Keep `experimental-features` and the empty `build-users-group =`
(#750) intact.

Keys/URLs are taken verbatim from the repo's existing source of truth,
`CONTRIBUTE.md:44-45` (the public `vig-os` Cachix cache + upstream
`cache.nixos.org`). These are PUBLIC keys, safe to bake.

### Baked `/etc/nix/nix.conf` — before / after

Before:
```conf
experimental-features = nix-command flakes
accept-flake-config = true
build-users-group =
```

After (verified by extracting the built image tarball's bootstrap
layer):
```conf
experimental-features = nix-command flakes
substituters = https://cache.nixos.org https://vig-os.cachix.org
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= vig-os.cachix.org-1:yoOYRi3bvnM6ThxO0joLt7vtzhTfkq3r6jykeUMg7Bk=
build-users-group =
```

### Cachix key source

`vig-os.cachix.org-1:yoOYRi3bvnM6ThxO0joLt7vtzhTfkq3r6jykeUMg7Bk=` —
`CONTRIBUTE.md:45` (the documented `vig-os` Cachix substituter setup).
Not invented.

## Tests

Extended `tests/test_image.py::TestNixConfiguration` (alongside the
existing #749 `build-users-group` assertions) with three testinfra
checks against the baked nix.conf:
- `test_nix_conf_does_not_accept_flake_config` — asserts
`accept-flake-config = true` is gone.
- `test_nix_conf_bakes_explicit_substituters` — asserts both cache URLs
present.
- `test_nix_conf_bakes_trusted_public_keys` — asserts both public keys
present.

## Verification

- `nix flake check --accept-flake-config` — all checks passed.
- `nix build .#devcontainerImage` — succeeded, substituted from caches
(no mass source rebuild); extracted the resulting tarball and confirmed
the baked nix.conf matches the "after" block above.
- `nixfmt --check flake.nix`, `ruff check/format` on the test, and
`pre-commit run --files ...` — all relevant hooks pass.
- The image-side testinfra assertions require a running container, so
they run in image CI rather than locally.

## Branch note

The originally-suggested `security/` branch prefix is rejected by the
repo's mandatory `no-commit-to-branch` hook (allowed types:
`feature|bugfix|hotfix|release|docs|test|refactor`, plus `chore/` and
`worktree/`). A security fix maps to `bugfix`, so this PR is on
`bugfix/773-explicit-substituters`.

Closes #773.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant