mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 10:59:59 +00:00
\`utils/env/writer.py\` rejects multi-line values because bash \`source\`
and docker-compose \`--env-file\` cannot round-trip them
(introduced by a3782bf8d). \`scripts/tests/code/run.sh\` simultaneously
appended \`accept-flake-config = true\` to NIX_CONFIG before invoking
\`make setup\`, producing exactly the multi-line shape the writer
refuses. The test-environment workflow tripped this on every run
where \`06_test.sh\` → \`make test\` → \`scripts/tests/code/run.sh\`
fired (see actions/runs/26227822536/job/77180908867).
Fix the producer side, not the writer's layering:
* utils/env/handlers/nix_config.py: pull only the \`access-tokens\`
line out of NIX_CONFIG and write that single line. Other Nix
settings (\`accept-flake-config\`, \`experimental-features\`, …)
already live in /etc/nix/nix.conf via the Dockerfile inside the
dev container; host operators set them once in
~/.config/nix/nix.conf.
* scripts/tests/code/run.sh: drop the NIX_CONFIG mutation block.
It was a no-op for in-container test runs (the container's
/etc/nix/nix.conf already has accept-flake-config) and an active
bug for the env-pipeline (multi-line value crashed make dotenv).
The writer keeps its multi-line guard unchanged — the contract is
that .env carries single-line values, and producers must respect it.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
"""NIX_CONFIG: pass-through of the caller's access-tokens line, when present.
|
|
|
|
`.env` is consumed by bash `source` and docker-compose `--env-file`, neither
|
|
of which round-trips multi-line values; the writer therefore rejects them.
|
|
Other NIX_CONFIG settings (`accept-flake-config`, `experimental-features`, …)
|
|
belong in `/etc/nix/nix.conf` (Dockerfile injects them inside the dev
|
|
container; host operators set them once in `~/.config/nix/nix.conf`).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from typing import TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
from utils.env.builder import BuildContext, EnvBuilder
|
|
|
|
KEY = "NIX_CONFIG"
|
|
COMMENT = "Pass-through of the caller's NIX_CONFIG access-tokens line, when present."
|
|
|
|
|
|
def apply(eb: EnvBuilder, ctx: BuildContext) -> None:
|
|
nix_config = os.environ.get("NIX_CONFIG", "")
|
|
access_tokens_line = next(
|
|
(
|
|
line.strip()
|
|
for line in nix_config.splitlines()
|
|
if line.lstrip().startswith("access-tokens")
|
|
),
|
|
"",
|
|
)
|
|
if access_tokens_line:
|
|
eb.set(KEY, access_tokens_line, comment=COMMENT)
|