This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

tools: extract build-installer-iso to separate tool

+93 -76
-76
flake.nix
··· 168 168 }; 169 169 }; 170 170 clan-cli = clan-core.packages.${system}.clan-cli; 171 - 172 - # Script to build installer ISO with custom vars 173 - build-installer-iso = pkgs.writeShellScriptBin "build-installer-iso" '' 174 - set -euo pipefail 175 - set -x 176 - 177 - # Default values 178 - OUTPUT="installer.iso" 179 - ARCH="x86_64-linux" # Default to x86_64-linux for cross-compilation 180 - VARS_DIR="" 181 - 182 - usage() { 183 - cat <<EOF 184 - Usage: $0 [OPTIONS] 185 - 186 - Build a NixOS installer ISO with custom vars appended. 187 - 188 - OPTIONS: 189 - -o, --output FILE Output ISO file (default: installer.iso) 190 - -a, --arch ARCH Architecture: x86_64-linux or aarch64-linux (default: x86_64-linux) 191 - -v, --vars DIR Directory containing vars to append to ISO 192 - -h, --help Show this help message 193 - 194 - EXAMPLE: 195 - $0 -o my-installer.iso -v ./my-vars -a x86_64-linux 196 - EOF 197 - } 198 - 199 - # Parse arguments 200 - while [[ $# -gt 0 ]]; do 201 - case $1 in 202 - -o|--output) 203 - OUTPUT="$2" 204 - shift 2 205 - ;; 206 - -a|--arch) 207 - ARCH="$2" 208 - shift 2 209 - ;; 210 - -v|--vars) 211 - VARS_DIR="$2" 212 - shift 2 213 - ;; 214 - -h|--help) 215 - usage 216 - exit 0 217 - ;; 218 - *) 219 - echo "Unknown option: $1" 220 - usage 221 - exit 1 222 - ;; 223 - esac 224 - done 225 - 226 - # Build the base ISO 227 - echo "Building base ISO for $ARCH..." 228 - BASE_ISO=$(nix build -L --no-link --print-out-paths ${self}#clanInternals.machines.$ARCH.installer.config.system.build.images.iso-installer) 229 - 230 - if [ -z "$VARS_DIR" ]; then 231 - # No vars specified, just copy the base ISO 232 - echo "No vars directory specified, copying base ISO..." 233 - cp "$BASE_ISO"/iso/*.iso "$OUTPUT" 234 - else 235 - # Append vars using xorriso - preserve boot structure 236 - echo "Appending vars from $VARS_DIR to ISO..." 237 - ${pkgs.xorriso}/bin/xorriso \ 238 - -indev "$BASE_ISO"/iso/*.iso \ 239 - -outdev "$OUTPUT" \ 240 - -boot_image any replay \ 241 - -map "$VARS_DIR" /vars \ 242 - -commit_eject all 243 - fi 244 - 245 - echo "ISO created: $OUTPUT" 246 - ''; 247 171 }; 248 172 devShells.default = pkgs.mkShell { 249 173 packages = [
+73
tools/build-installer-iso/build-installer-iso.sh
··· 1 + #!/usr/bin/env bash 2 + set -euo pipefail 3 + set -x 4 + 5 + # Default values 6 + OUTPUT="installer.iso" 7 + ARCH="x86_64-linux" # Default to x86_64-linux for cross-compilation 8 + VARS_DIR="" 9 + 10 + usage() { 11 + cat <<EOF 12 + Usage: $0 [OPTIONS] 13 + 14 + Build a NixOS installer ISO with custom vars appended. 15 + 16 + OPTIONS: 17 + -o, --output FILE Output ISO file (default: installer.iso) 18 + -a, --arch ARCH Architecture: x86_64-linux or aarch64-linux (default: x86_64-linux) 19 + -v, --vars DIR Directory containing vars to append to ISO 20 + -h, --help Show this help message 21 + 22 + EXAMPLE: 23 + $0 -o my-installer.iso -v ./my-vars -a x86_64-linux 24 + EOF 25 + } 26 + 27 + # Parse arguments 28 + while [[ $# -gt 0 ]]; do 29 + case $1 in 30 + -o|--output) 31 + OUTPUT="$2" 32 + shift 2 33 + ;; 34 + -a|--arch) 35 + ARCH="$2" 36 + shift 2 37 + ;; 38 + -v|--vars) 39 + VARS_DIR="$2" 40 + shift 2 41 + ;; 42 + -h|--help) 43 + usage 44 + exit 0 45 + ;; 46 + *) 47 + echo "Unknown option: $1" 48 + usage 49 + exit 1 50 + ;; 51 + esac 52 + done 53 + 54 + # Build the base ISO 55 + echo "Building base ISO for $ARCH..." 56 + BASE_ISO=$(nix build -L --no-link --print-out-paths "$FLAKE_ROOT#clanInternals.machines.$ARCH.installer.config.system.build.images.iso-installer") 57 + 58 + if [ -z "$VARS_DIR" ]; then 59 + # No vars specified, just copy the base ISO 60 + echo "No vars directory specified, copying base ISO..." 61 + cp "$BASE_ISO"/iso/*.iso "$OUTPUT" 62 + else 63 + # Append vars using xorriso - preserve boot structure 64 + echo "Appending vars from $VARS_DIR to ISO..." 65 + xorriso \ 66 + -indev "$BASE_ISO"/iso/*.iso \ 67 + -outdev "$OUTPUT" \ 68 + -boot_image any replay \ 69 + -map "$VARS_DIR" /vars \ 70 + -commit_eject all 71 + fi 72 + 73 + echo "ISO created: $OUTPUT"
+20
tools/build-installer-iso/flake-module.nix
··· 1 + { self, ... }: 2 + { 3 + perSystem = 4 + { pkgs, ... }: 5 + { 6 + packages.build-installer-iso = pkgs.writeShellApplication { 7 + name = "build-installer-iso"; 8 + runtimeInputs = with pkgs; [ 9 + xorriso 10 + coreutils 11 + nix 12 + ]; 13 + text = '' 14 + # Export flake root for the script to use 15 + export FLAKE_ROOT="${self}" 16 + ${builtins.readFile ./build-installer-iso.sh} 17 + ''; 18 + }; 19 + }; 20 + }