From 20ac77d8a0de564c6c276fa22f11c90302a88686 Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Sat, 31 Oct 2026 15:18:37 +0000 Subject: [PATCH] devshell: Accept flake config in build-n-switch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pass `--accept-flake-config` explicitly because `doas` drops the devshell configuration that enables it. This avoids prompts for the flake’s binary cache settings when rebuilding as root. --- AGENTS.md | 2 +- devshell/commands.nix | 3 ++- docs/deployment.md | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 581c62d..4336849 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -35,7 +35,7 @@ see its help, or browse `devshell/commands.nix` / `devshell/install.nix` / `devs Common ones: - `fmt` — format Nix with `nixpkgs-fmt` (the canonical formatter here). - `build-system [nix args]` — build a NixOS system's `toplevel`. -- `build-n-switch ` — wraps `doas nixos-rebuild --flake .`. +- `build-n-switch ` — wraps `doas nixos-rebuild --accept-flake-config --flake .`. - `build-home ` / `home-switch` — build / switch a home-manager config. - `run-vm ` — build & boot a system as a dev VM (installs `.keys/dev.key` into the VM). - `build-iso` / `build-kexec` / `build-netboot ` — alternate build outputs via `config.my.buildAs.*`. diff --git a/devshell/commands.nix b/devshell/commands.nix index 83fbd43..523f24b 100644 --- a/devshell/commands.nix +++ b/devshell/commands.nix @@ -106,7 +106,8 @@ in # HACK: Upstream changes in Git + Nix makes this necessary # https://github.com/NixOS/nix/issues/10202 doas git config --global --add safe.directory "$PWD" - doas nixos-rebuild --flake . "$@" + # doas drops the devshell's NIX_USER_CONF_FILES, including accept-flake-config. + doas nixos-rebuild --accept-flake-config --flake . "$@" ''; } { diff --git a/docs/deployment.md b/docs/deployment.md index 69b864b..fee808c 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -82,7 +82,7 @@ command with no arguments for its help. From |---|---| | `check-system [nix args]` | Evaluates `.#nixosConfigurations."".config.system.build.toplevel.drvPath` — catches module/option errors without building. Prefer this to validate a config change. | | `build-system [nix args]` | Builds the system's `toplevel` (extra args pass through to `nix build`). | -| `build-n-switch ` | `doas nixos-rebuild --flake .` (adds the repo as a git `safe.directory` for root first). | +| `build-n-switch ` | `doas nixos-rebuild --accept-flake-config --flake .` (accepts the flake's cache settings and adds the repo as a git `safe.directory` for root first). | | `build-home [nix args]` | Builds `.#homeConfigurations."".activationPackage`. | | `home-switch [args]` | `home-manager switch --flake .`. | | `deploy [args]` | `deploy-rs --skip-checks` (wrapper package in `devshell/default.nix`). |