diff --git a/docs/demo.md b/docs/demo.md index 98cde2c..60e1a07 100644 --- a/docs/demo.md +++ b/docs/demo.md @@ -151,13 +151,24 @@ rage -d -i .devenv/state/slop-demo/dev-age.key <(git -C .devenv/state/slop-demo/ ### Deploys The repository's `flake.nix` has a deploy-rs node, `box`, with one profile, `demo`, deployed as -root: a small app whose activation writes its version to `/run/demo/version`. Its `nixpkgs` is -locked to this repository's, so the builder has it already, and it uses nixpkgs' build of -deploy-rs, so a build takes moments. In `~/repo` on the agents' VM: +root: an app whose activation writes its version to `/run/demo/version`. + +- **Its `nixpkgs`** is locked to this repository's, so the builder has it already, and it uses + nixpkgs' build of deploy-rs, so nothing big needs building. +- **Its parts** stand in for a bigger build, so the progress in `slop` and the web app has + something to show. There are `layers` of `width` parts, and each layer builds once the one + below it has, so a build takes about a minute and a half. Each part takes 15 to 30 seconds and + adds a few MiB to copy. +- **Their contents** follow from `version` alone, and the builder keeps what it built in the + host's store. So a version that's been built before only evaluates, and copies what the box VM + doesn't have. A version that hasn't been built yet rebuilds every part, so `demo-bump` (in + [`bump.nix`](../nix/demo/bump.nix)) sets a new one each time, from the time unless you give + one, and pushes it on a branch of its own. + +In `~/repo` on the agents' VM: ```sh -sed -i 's/version = "1.0"/version = "1.1"/' flake.nix -git switch -c bump && git commit -am "Bump the app" && git push origin bump +demo-bump slop deploy box ` on the host moves it, standing in for a person mergin - `secrets/app.env.age` holds `DB_USER` and `DB_PASSWORD`; `secrets/wg.key.age` is a WireGuard private key, as a whole file. -`flake.nix` has a deploy-rs node, `box`, with one profile, `demo`: a small app whose activation -writes its version to `/run/demo/version`. +`flake.nix` has a deploy-rs node, `box`, with one profile, `demo`: an app whose activation writes +its version to `/run/demo/version`. Its parts take a while to build and add a few MiB each, so +builds and copies show their progress. They follow from the version, so only a version that +hasn't been built before rebuilds them. Change secrets with `slop secret` (`slop guide` explains it), commit, and push a branch. Deploy a pushed commit with `slop deploy box`. diff --git a/nix/demo/repo/flake.nix b/nix/demo/repo/flake.nix index df7f8cc..cdf4c21 100644 --- a/nix/demo/repo/flake.nix +++ b/nix/demo/repo/flake.nix @@ -13,13 +13,45 @@ # Change this, push a branch and `slop deploy box`: the approval shows the version change version = "1.0"; + # Stand-ins for a bigger build, so its progress and the copy's have something to show: + # `layers` of `width` parts, each layer built once the one before it is, like a chain of + # dependencies. Each part takes 15 to 30 seconds and adds a few MiB to copy. Their contents + # follow from the version alone, so a version that's been built before is already in the + # builder's store, and only a new one rebuilds them all. + layers = 3; + width = 4; + partCount = layers * width; + + # Layer `n`, whose parts each depend on all of the layer below + layer = n: below: builtins.genList + (i: + let + index = n * width + i; + name = "demo-part-${toString index}-${version}"; + size = 2 + pkgs.lib.mod index 6; + in + pkgs.runCommand name { inherit below; } '' + for step in 1 2 3 4 5 6; do + echo "part ${toString index}: step $step" + sleep ${toString (3 + pkgs.lib.mod index 3)} + done + head -c ${toString size}M < <(yes "demo app ${version}, part ${toString index}") > $out + '') + width; + layered = builtins.foldl' + (built: n: let next = layer n built.last; in { all = built.all ++ next; last = next; }) + { all = [ ]; last = [ ]; } + (builtins.genList (n: n) layers); + parts = layered.all; + app = pkgs.writeTextFile { name = "demo-app-${version}"; destination = "/bin/demo-app"; executable = true; text = '' #!${pkgs.runtimeShell} - echo "demo app ${version}" + # Its parts: ${toString parts} + echo "demo app ${version}, in ${toString partCount} parts" ''; };