Update push.sh to support both NixOS and service deploys

t-266.5·WorkTask·
·
·
·Omni/Ide.hs
Parent:t-266·Created2 months ago·Updated2 months ago

Dependencies

Description

Edit

Enhance push.sh to handle both NixOS deploys and service deploys.

File to Modify

  • Omni/Ide/push.sh - Add service deploy mode

Current Behavior (preserve for .nix targets)

# Builds NixOS, copies to host, runs switch-to-configuration
target="$1"
what=$(realpath "${CODEROOT:?}/_/nix/$target")
where=<extracted from systemd service>
nix copy --to ssh://"$USER"@"$where" "$what"
ssh "$USER"@"$where" sudo nix-env --profile /nix/var/nix/profiles/system --set "$what"
ssh "$USER"@"$where" sudo switch-to-configuration switch

New Behavior (for non-.nix targets)

#!/usr/bin/env bash
target="$1"

if [[ "$target" == *.nix ]]; then
    # NixOS deploy (existing behavior)
    bild "$target"
    # ... existing nix copy + switch logic ...
else
    # Service deploy (new behavior)
    
    # 1. Build and cache
    store_path=$(bild --cache "$target" | grep '^/nix/store')
    
    # 2. Extract service name from target path
    # Biz/PodcastItLater/Web.py -> podcastitlater-web
    service_name=$(derive_service_name "$target")
    
    # 3. Update manifest in S3
    # Could shell out to python or use aws cli + jq
    python3 -c "
import Omni.Deploy.Manifest as M
manifest = M.load_manifest_from_s3('omni-nix-cache')
manifest = M.update_service(manifest, '$service_name', '$store_path')
M.save_manifest_to_s3(manifest, 'omni-nix-cache')
"
    
    echo "Deployed $service_name, deployer will pick up in <5 min"
fi

S3 Configuration

Use same credentials as bild:

  • Bucket: omni-nix-cache
  • Endpoint: nyc3.digitaloceanspaces.com
  • Profile: digitalocean

Service Name Derivation

Convert namespace path to service name:

  • Biz/PodcastItLater/Web.py -> podcastitlater-web
  • Biz/Storybook.py -> storybook

Dependencies

  • t-266.3: bild --cache must work
  • t-266.4: Manifest.py must exist for updating manifest

Testing

# NixOS deploy (should work as before)
push.sh Biz.nix

# Service deploy (new)
push.sh Biz/PodcastItLater/Web.py
# Should update manifest.json in S3

Timeline (2)

🔄[human]Open → InProgress2 months ago
🔄[human]InProgress → Done2 months ago