From 271cc90223e6eef3cb9cd9942b6fcb0ca120637b Mon Sep 17 00:00:00 2001 From: horyzon Date: Sat, 18 Jul 2026 17:52:21 +0000 Subject: [PATCH 01/12] feat: exposes top-level writer targets --- modules/bootstrap/default.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/bootstrap/default.nix b/modules/bootstrap/default.nix index 4d8698e..75fe4e1 100644 --- a/modules/bootstrap/default.nix +++ b/modules/bootstrap/default.nix @@ -60,7 +60,7 @@ let inputs = ''{ flake-file.url = "github:vic/flake-file"; }''; notice = pkgs.writeText "notice" '' # DO-NOT-EDIT. Generated by github:vic/flake-file from flake-file.nix. Regen with: - # nix-shell https://github.com/vic/flake-file/archive/main.zip -A flake-file.sh --run bootstrap + # nix-shell https://github.com/vic/flake-file/archive/main.zip -A bootstrap --run bootstrap ''; in pkgs.writeShellApplication { @@ -69,7 +69,7 @@ let if ! test -f flake-file.nix; then cp flake.nix flake-file.nix fi - nix-shell ${../..} -A flake-file.sh --run write-flake \ + nix-shell ${../..} -A write-flake --run write-flake \ --arg modules ./flake-file.nix \ --arg do-not-edit ${notice} \ --argstr outputs flake-module \ @@ -80,5 +80,7 @@ let evaled = lib.evalModules { modules = [ module ]; }; + appPackages = lib.mapAttrs (_: app: app pkgs) evaled.config.flake-file.apps; + in -evaled.config +evaled.config // appPackages From daac19c63a45f583a00c9a9d21a2775e465a7194 Mon Sep 17 00:00:00 2001 From: horyzon Date: Sat, 18 Jul 2026 17:54:33 +0000 Subject: [PATCH 02/12] test: covers public write-flake target --- dev/_bootstrap-tests.nix | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/dev/_bootstrap-tests.nix b/dev/_bootstrap-tests.nix index d535220..f28316d 100644 --- a/dev/_bootstrap-tests.nix +++ b/dev/_bootstrap-tests.nix @@ -19,6 +19,16 @@ let outputs = _: { }; }; + broken-app = bootstrap { + inputs.empty.url = "github:vic/empty-flake"; + outputs = _: { }; + flake-file.apps.write-broken = + pkgs: + pkgs.runCommand "write-broken" { } '' + exit 1 + ''; + }; + all-inputs-schemes = bootstrap { inputs.simple.url = "github:vic/empty-flake"; inputs.withBranch.url = "github:vic/empty-flake/main"; @@ -84,6 +94,32 @@ let ''; }; + test-flake-public = pkgs.writeShellApplication { + name = "test-flake-public"; + runtimeInputs = [ + pkgs.nix + (empty.write-flake pkgs) + ]; + text = '' + write-flake + cat ${outdir}/flake.nix + grep github:vic/empty-flake ${outdir}/flake.nix + ''; + }; + + test-flake-public-ignores-broken-app = pkgs.writeShellApplication { + name = "test-flake-public-ignores-broken-app"; + runtimeInputs = [ + pkgs.nix + (broken-app.write-flake pkgs) + ]; + text = '' + write-flake + cat ${outdir}/flake.nix + grep github:vic/empty-flake ${outdir}/flake.nix + ''; + }; + test-npins = pkgs.writeShellApplication { name = "test-npins"; runtimeInputs = [ @@ -245,6 +281,8 @@ pkgs.mkShell { buildInputs = [ test-inputs test-flake + test-flake-public + test-flake-public-ignores-broken-app test-unflake test-npins test-npins-schemes From 19d3c4876e27c9e62ea6bbcec873bcd92e76cb86 Mon Sep 17 00:00:00 2001 From: horyzon Date: Sat, 18 Jul 2026 18:02:40 +0000 Subject: [PATCH 03/12] docs: uses standalone bootstrap targets --- README.md | 2 +- docs/src/content/docs/index.mdx | 2 +- docs/src/content/docs/reference/bootstrap.mdx | 9 +++++++-- docs/src/content/docs/tutorials/bootstrap.mdx | 6 +++--- docs/src/content/docs/tutorials/migrate-flake-parts.mdx | 2 +- docs/src/content/docs/tutorials/migrate-no-flakes.mdx | 4 ++-- .../content/docs/tutorials/migrate-traditional-flake.mdx | 4 ++-- 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 4b1103b..7d3f55e 100644 --- a/README.md +++ b/README.md @@ -55,5 +55,5 @@ This means ```shell mv flake.nix flake-file.nix -nix-shell https://github.com/vic/flake-file/archive/main.zip -A flake-file.sh --run bootstrap +nix-shell https://github.com/vic/flake-file/archive/main.zip -A bootstrap --run bootstrap ``` diff --git a/docs/src/content/docs/index.mdx b/docs/src/content/docs/index.mdx index 53eb547..71c2c0d 100644 --- a/docs/src/content/docs/index.mdx +++ b/docs/src/content/docs/index.mdx @@ -47,7 +47,7 @@ Ever wanted to interpolate a string just to discover inputs are **NOT REAL** Nix ```shell mv flake.nix flake-file.nix -nix-shell https://github.com/vic/flake-file/archive/main.tar.gz -A flake-file.sh --run bootstrap +nix-shell https://github.com/vic/flake-file/archive/main.tar.gz -A bootstrap --run bootstrap ``` ### Features diff --git a/docs/src/content/docs/reference/bootstrap.mdx b/docs/src/content/docs/reference/bootstrap.mdx index d025aa3..1944d76 100644 --- a/docs/src/content/docs/reference/bootstrap.mdx +++ b/docs/src/content/docs/reference/bootstrap.mdx @@ -9,12 +9,17 @@ The bootstrap command lets you generate `flake.nix`, `unflake.nix`, `.tack/`, or ```shell nix-shell https://github.com/vic/flake-file/archive/refs/heads/main.zip \ - -A flake-file.sh --run [--arg ]... + -A --run [--arg ]... ``` ## Apps -The `flake-file.sh` shell provides these commands: +Each app is available as a standalone top-level target. Use the matching +`-A ` target when running one command so unrelated backends are not +realized. Use `-A flake-file.sh` only when you want an aggregate shell with all +commands. + +The bootstrap entrypoint provides these commands: | App | Description | | --- | --- | diff --git a/docs/src/content/docs/tutorials/bootstrap.mdx b/docs/src/content/docs/tutorials/bootstrap.mdx index ef953ec..38b3c5c 100644 --- a/docs/src/content/docs/tutorials/bootstrap.mdx +++ b/docs/src/content/docs/tutorials/bootstrap.mdx @@ -23,12 +23,12 @@ echo '{ inputs.flake-file.url = "github:vic/flake-file"; }' > flake-file.nix # Generate flake.nix or unflake.nix or npins from flake-file.nix nix-shell https://github.com/vic/flake-file/archive/refs/heads/main.zip \ - -A flake-file.sh --run write-flake --arg modules ./flake-file.nix + -A write-flake --run write-flake --arg modules ./flake-file.nix ``` > See also: all [bootstrap command args](/reference/bootstrap) -Replace `write-flake` with `write-inputs`, `write-unflake`, `write-tack`, or `write-npins` to target a different backend. +Replace `write-flake` in both `-A write-flake` and `--run write-flake` with `write-inputs`, `write-unflake`, `write-tack`, or `write-npins` to target a different backend. ## Using a modules directory @@ -37,7 +37,7 @@ Replace `write-flake` with `write-inputs`, `write-unflake`, `write-tack`, or `wr ```shell "./modules" nix-shell https://github.com/vic/flake-file/archive/refs/heads/main.zip \ - -A flake-file.sh --run write-flake --arg modules ./modules + -A write-flake --run write-flake --arg modules ./modules ``` This is useful when you already have module files and just need the initial `flake.nix` to be generated before Nix can evaluate the flake itself. diff --git a/docs/src/content/docs/tutorials/migrate-flake-parts.mdx b/docs/src/content/docs/tutorials/migrate-flake-parts.mdx index f61d298..27883a0 100644 --- a/docs/src/content/docs/tutorials/migrate-flake-parts.mdx +++ b/docs/src/content/docs/tutorials/migrate-flake-parts.mdx @@ -65,7 +65,7 @@ And now, lets replace `flake.nix` using bootstrapping magic step: ```shell "./modules" "flake-parts" nix-shell https://github.com/vic/flake-file/archive/main.tar.gz \ - -A flake-file.sh --run write-flake \ + -A write-flake --run write-flake \ --arg modules ./modules --argstr outputs flake-parts ``` diff --git a/docs/src/content/docs/tutorials/migrate-no-flakes.mdx b/docs/src/content/docs/tutorials/migrate-no-flakes.mdx index 6c9aad1..8dd62fa 100644 --- a/docs/src/content/docs/tutorials/migrate-no-flakes.mdx +++ b/docs/src/content/docs/tutorials/migrate-no-flakes.mdx @@ -54,7 +54,7 @@ And now, lets generate `./npins` from `./flake-file.nix`. ```shell "./flake-file.nix" "write-npins" nix-shell https://github.com/vic/flake-file/archive/main.tar.gz \ - -A flake-file.sh --run write-npins --arg modules ./flake-file.nix + -A write-npins --run write-npins --arg modules ./flake-file.nix ``` > See also: all [bootstrap command args](/reference/bootstrap) @@ -118,7 +118,7 @@ To update npins from inputs at ./modules do: ```shell "./modules" "write-npins" nix-shell https://github.com/vic/flake-file/archive/main.tar.gz \ - -A flake-file.sh --run write-npins --arg modules ./modules + -A write-npins --run write-npins --arg modules ./modules ``` ### `(A)` flake-like inputs diff --git a/docs/src/content/docs/tutorials/migrate-traditional-flake.mdx b/docs/src/content/docs/tutorials/migrate-traditional-flake.mdx index e5c51cd..ae9f132 100644 --- a/docs/src/content/docs/tutorials/migrate-traditional-flake.mdx +++ b/docs/src/content/docs/tutorials/migrate-traditional-flake.mdx @@ -13,7 +13,7 @@ You can use [`templates/minimal`](https://github.com/vic/flake-file/tree/main/te ```shell mv flake.nix flake-file.nix -nix-shell https://github.com/vic/flake-file/archive/main.tar.gz -A flake-file.sh --run bootstrap +nix-shell https://github.com/vic/flake-file/archive/main.tar.gz -A bootstrap --run bootstrap ``` ## The new `flake.nix` (static Nix) @@ -64,7 +64,7 @@ When your input changes, run it again to propagate your input changes into the **static** `flake.nix`. ```shell -nix-shell https://github.com/vic/flake-file/archive/main.zip -A flake-file.sh --run bootstrap +nix-shell https://github.com/vic/flake-file/archive/main.zip -A bootstrap --run bootstrap ```