From 79ff0b8aa4508925698582120d3f1649831f0394 Mon Sep 17 00:00:00 2001 From: John Ogle Date: Sat, 10 Jan 2026 13:06:52 -0800 Subject: [PATCH] feat: Move bootstrap/build-liveusb scripts to flake apps - Move bootstrap.sh to scripts/ and add as flake app - Move build-liveusb.sh to scripts/ and add as flake app - Update usage comments to show nix run commands - Improve build-liveusb.sh with better error handling (set -euo pipefail) - Remove emojis from output messages for cleaner log output Scripts can now be run consistently via: nix run .#bootstrap -- nix run .#build-liveusb Implements bead: nixos-configs-bli --- build-liveusb.sh | 19 ------------------- flake.nix | 18 ++++++++++++++++++ bootstrap.sh => scripts/bootstrap.sh | 4 ++-- scripts/build-liveusb.sh | 22 ++++++++++++++++++++++ 4 files changed, 42 insertions(+), 21 deletions(-) delete mode 100755 build-liveusb.sh rename bootstrap.sh => scripts/bootstrap.sh (76%) mode change 100755 => 100644 create mode 100644 scripts/build-liveusb.sh diff --git a/build-liveusb.sh b/build-liveusb.sh deleted file mode 100755 index f0c98c1..0000000 --- a/build-liveusb.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -# Build Live USB ISO from flake configuration -# Creates an uncompressed ISO suitable for Ventoy and other USB boot tools - -set -e - -echo "Building Live USB ISO..." -nix build .#nixosConfigurations.live-usb.config.system.build.isoImage --show-trace - -if [ -f "./result/iso/"*.iso ]; then - iso_file=$(ls ./result/iso/*.iso) - echo "✅ Build complete!" - echo "📁 ISO location: $iso_file" - echo "💾 Ready for Ventoy or dd to USB" -else - echo "❌ Build failed - no ISO file found" - exit 1 -fi \ No newline at end of file diff --git a/flake.nix b/flake.nix index 93a194e..a0b0422 100644 --- a/flake.nix +++ b/flake.nix @@ -275,6 +275,16 @@ export PATH="${pkgs.lib.makeBinPath commonDeps}:$PATH" ${builtins.readFile ./scripts/upgrade.sh} ''; + + bootstrap = pkgs.writeShellScriptBin "bootstrap" '' + export PATH="${pkgs.lib.makeBinPath commonDeps}:$PATH" + ${builtins.readFile ./scripts/bootstrap.sh} + ''; + + build-liveusb = pkgs.writeShellScriptBin "build-liveusb" '' + export PATH="${pkgs.lib.makeBinPath commonDeps}:$PATH" + ${builtins.readFile ./scripts/build-liveusb.sh} + ''; in { update-doomemacs = { type = "app"; @@ -292,6 +302,14 @@ type = "app"; program = "${upgrade}/bin/upgrade"; }; + bootstrap = { + type = "app"; + program = "${bootstrap}/bin/bootstrap"; + }; + build-liveusb = { + type = "app"; + program = "${build-liveusb}/bin/build-liveusb"; + }; } ); }; diff --git a/bootstrap.sh b/scripts/bootstrap.sh old mode 100755 new mode 100644 similarity index 76% rename from bootstrap.sh rename to scripts/bootstrap.sh index 329f1b3..f423e72 --- a/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # bootstrap.sh -# Usage: sudo ./bootstrap.sh +# Usage: nix run .#bootstrap -- +# Or: sudo ./scripts/bootstrap.sh set -euo pipefail NEW_HOSTNAME="${1:?missing hostname}" @@ -8,4 +9,3 @@ FLAKE_URI="git+https://git.johnogle.info/johno/nixos-configs.git#${NEW_HOSTNAME} export NIX_CONFIG="experimental-features = nix-command flakes" nixos-rebuild switch --flake "$FLAKE_URI" - diff --git a/scripts/build-liveusb.sh b/scripts/build-liveusb.sh new file mode 100644 index 0000000..a0fbd39 --- /dev/null +++ b/scripts/build-liveusb.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# Build Live USB ISO from flake configuration +# Creates an uncompressed ISO suitable for Ventoy and other USB boot tools +# Usage: nix run .#build-liveusb +# Or: ./scripts/build-liveusb.sh + +set -euo pipefail + +REPO_ROOT="${REPO_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}" + +echo "Building Live USB ISO..." +nix build "${REPO_ROOT}#nixosConfigurations.live-usb.config.system.build.isoImage" --show-trace + +if ls "${REPO_ROOT}/result/iso/"*.iso 1> /dev/null 2>&1; then + iso_file=$(ls "${REPO_ROOT}/result/iso/"*.iso) + echo "Build complete!" + echo "ISO location: $iso_file" + echo "Ready for Ventoy or dd to USB" +else + echo "Build failed - no ISO file found" + exit 1 +fi -- 2.49.1