Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
38 changes: 38 additions & 0 deletions dev/_bootstrap-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -84,6 +94,32 @@ let
'';
};

test-flake-public = pkgs.writeShellApplication {
name = "test-flake-public";
runtimeInputs = [
pkgs.nix
empty.write-flake
];
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
];
text = ''
write-flake
cat ${outdir}/flake.nix
grep github:vic/empty-flake ${outdir}/flake.nix
'';
};

test-npins = pkgs.writeShellApplication {
name = "test-npins";
runtimeInputs = [
Expand Down Expand Up @@ -246,6 +282,8 @@ pkgs.mkShell {
buildInputs = [
test-inputs
test-flake
test-flake-public
test-flake-public-ignores-broken-app
test-unflake
test-npins
test-npins-schemes
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions docs/src/content/docs/reference/bootstrap.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <app> [--arg <name> <value>]...
-A <app> --run <app> [--arg <name> <value>]...
```

## Apps

The `flake-file.sh` shell provides these commands:
Each app is available as a standalone top-level target. Use the matching
`-A <app>` 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 |
| --- | --- |
Expand Down
6 changes: 3 additions & 3 deletions docs/src/content/docs/tutorials/bootstrap.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

> <small>See also: all [bootstrap command args](/reference/bootstrap)</small>

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
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/tutorials/migrate-flake-parts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/tutorials/migrate-no-flakes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

> <small>See also: all [bootstrap command args](/reference/bootstrap)</small>
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/tutorials/migrate-traditional-flake.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
```

<Aside title="You are done!">
Expand Down
10 changes: 7 additions & 3 deletions modules/bootstrap/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 \
Expand All @@ -80,5 +80,9 @@ let

evaled = lib.evalModules { modules = [ module ]; };

appPackages = lib.mapAttrs (
_: app: pkgs.mkShell { buildInputs = [ (app pkgs) ]; }
) evaled.config.flake-file.apps;

in
evaled.config
evaled.config // appPackages
Loading