let pkgs = import {}; # Build script for a specific machine buildForMachine = name: pkgs.writeShellScriptBin "build-${name}" '' set -e BUILD_DIR="./build/${name}" echo "Building web-app for ${name}..." # Clean and create build directory rm -rf "$BUILD_DIR" mkdir -p "$BUILD_DIR" # Copy web-app source cp -r ./web-app/* "$BUILD_DIR/" # Copy machine-specific .env echo "Copying machine-specific .env..." cp ./machine-specific/${name}/env/.env "$BUILD_DIR/.env" # Copy machine-specific images to public folder echo "Copying machine-specific images to public..." cp -r ./machine-specific/${name}/images/* "$BUILD_DIR/public/" # Copy machine-specific logo to assets echo "Copying machine-specific logo to assets..." mkdir -p "$BUILD_DIR/src/assets" cp ./machine-specific/${name}/images/logo.png "$BUILD_DIR/src/assets/logo.png" # Build the web-app echo "Running build..." cd "$BUILD_DIR" ${pkgs.nodejs}/bin/npm run build echo "Build complete for ${name}! Output in $BUILD_DIR/dist" ''; in { # Example machine build (copy this line for each machine) # Replace "example-machine" with your machine name example-machine = buildForMachine "example-machine"; # Add more machines here: # machine1 = buildForMachine "machine1"; # machine2 = buildForMachine "machine2"; # Build all machines (update this list with your machines) all = pkgs.writeShellScriptBin "build-all" '' set -e echo "Building for all machines..." ${(buildForMachine "example-machine")}/bin/build-example-machine # Add your machines here: # ${(buildForMachine "machine1")}/bin/build-machine1 # ${(buildForMachine "machine2")}/bin/build-machine2 echo "All builds complete!" ''; }