Skip to content

Commit fffae21

Browse files
committed
cleanup
1 parent d23d106 commit fffae21

File tree

16 files changed

+85
-27
lines changed

16 files changed

+85
-27
lines changed

cli/dev.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"strings"
1010
"time"
1111

12-
"codeberg.org/d-buckner/bloud-v3/cli/vm"
12+
"codeberg.org/d-buckner/bloud/cli/vm"
1313
)
1414

1515
// localExec runs a command on the host machine (not in VM)
@@ -20,7 +20,7 @@ func localExec(name string, args ...string) *exec.Cmd {
2020
const (
2121
devVMName = "bloud"
2222
devTmuxSession = "bloud-dev"
23-
devProjectInVM = "/home/bloud.linux/bloud-v3"
23+
devProjectInVM = "/home/bloud.linux/bloud"
2424
)
2525

2626
var devPorts = []vm.PortForward{
@@ -310,6 +310,25 @@ func cmdServices() int {
310310
return 0
311311
}
312312

313+
func cmdDestroy() int {
314+
if !vm.Exists(devVMName) {
315+
log("VM does not exist")
316+
return 0
317+
}
318+
319+
// Kill port forwarding first
320+
_ = vm.KillPortForwarding(devVMName, devPorts[0].LocalPort)
321+
322+
log("Destroying dev VM...")
323+
if err := vm.Delete(devVMName); err != nil {
324+
errorf("Failed to destroy VM: %v", err)
325+
return 1
326+
}
327+
328+
log("Dev VM destroyed")
329+
return 0
330+
}
331+
313332
// isPortForwardingRunning checks if port forwarding is running for a port
314333
func isPortForwardingRunning(port int) bool {
315334
// Check for local SSH process doing port forwarding

cli/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module codeberg.org/d-buckner/bloud-v3/cli
1+
module codeberg.org/d-buckner/bloud/cli
22

33
go 1.24.0
44

cli/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"os"
66

7-
"codeberg.org/d-buckner/bloud-v3/cli/vm"
7+
"codeberg.org/d-buckner/bloud/cli/vm"
88
)
99

1010
const (
@@ -52,6 +52,8 @@ func main() {
5252
exitCode = cmdRebuild()
5353
case "depgraph":
5454
exitCode = cmdDepGraph()
55+
case "destroy":
56+
exitCode = cmdDestroy()
5557

5658
// Test commands (subcommand)
5759
case "test":
@@ -121,6 +123,7 @@ func printUsage() {
121123
fmt.Println(" shell [cmd] Shell into VM (or run a command)")
122124
fmt.Println(" rebuild Rebuild NixOS configuration")
123125
fmt.Println(" depgraph Generate Mermaid dependency graph from app metadata")
126+
fmt.Println(" destroy Destroy the dev VM completely")
124127
fmt.Println()
125128
fmt.Println("Test Commands (ephemeral environment, ports 8081/3001/5174):")
126129
fmt.Println(" test start Create fresh test VM and start services")

cli/test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"text/template"
1010
"time"
1111

12-
"codeberg.org/d-buckner/bloud-v3/cli/vm"
12+
"codeberg.org/d-buckner/bloud/cli/vm"
1313
)
1414

1515
const (
@@ -55,7 +55,7 @@ func generateTestConfig(templatePath, outputPath, projectRoot string) error {
5555
mainRepo := os.Getenv("BLOUD_MAIN_REPO")
5656
if mainRepo == "" {
5757
home, _ := os.UserHomeDir()
58-
mainRepo = filepath.Join(home, "Projects", "bloud-v3")
58+
mainRepo = filepath.Join(home, "Projects", "bloud")
5959
}
6060

6161
data := map[string]string{
@@ -137,7 +137,7 @@ func testStart() int {
137137
mainRepo := os.Getenv("BLOUD_MAIN_REPO")
138138
if mainRepo == "" {
139139
home, _ := os.UserHomeDir()
140-
mainRepo = filepath.Join(home, "Projects", "bloud-v3")
140+
mainRepo = filepath.Join(home, "Projects", "bloud")
141141
}
142142

143143
// Create mount directories and mount filesystems

docs/testing-plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Bloud-v3 Testing Plan
1+
# Bloud Testing Plan
22

33
This document outlines the comprehensive testing strategy for the orchestrator and NixOS modules.
44

integration/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@bloud/integration-tests",
33
"version": "0.1.0",
4+
"license": "AGPL-3.0-only",
45
"private": true,
56
"type": "module",
67
"scripts": {

lima/build-image.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,18 @@ build_on_vm() {
3737

3838
# Copy project to VM's temp directory (to avoid 9p permission issues)
3939
echo "Copying project to VM..."
40-
limactl shell nix-builder -- rm -rf /tmp/bloud-v3
41-
limactl shell nix-builder -- mkdir -p /tmp/bloud-v3
40+
limactl shell nix-builder -- rm -rf /tmp/bloud
41+
limactl shell nix-builder -- mkdir -p /tmp/bloud
4242
rsync -av --exclude='.git' --exclude='node_modules' --exclude='result*' \
43-
"$PROJECT_ROOT/" nix-builder:/tmp/bloud-v3/
43+
"$PROJECT_ROOT/" nix-builder:/tmp/bloud/
4444

4545
# Build the image
4646
echo "Building image..."
47-
limactl shell nix-builder -- bash -c "cd /tmp/bloud-v3 && nix build .#lima-image -o result-lima-image"
47+
limactl shell nix-builder -- bash -c "cd /tmp/bloud && nix build .#lima-image -o result-lima-image"
4848

4949
# Copy the result back
5050
mkdir -p "$IMG_DIR"
51-
limactl shell nix-builder -- cat /tmp/bloud-v3/result-lima-image/nixos.img > "$IMG_DIR/nixos-24.11-lima.img"
51+
limactl shell nix-builder -- cat /tmp/bloud/result-lima-image/nixos.img > "$IMG_DIR/nixos-24.11-lima.img"
5252

5353
echo "Image built: $IMG_DIR/nixos-24.11-lima.img"
5454
}

lima/dev

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
2020
VM_NAME="bloud"
2121
VM_USER="bloud"
2222
VM_PASSWORD="bloud"
23-
PROJECT_IN_VM="/home/bloud.linux/bloud-v3"
23+
PROJECT_IN_VM="/home/bloud.linux/bloud"
2424
TMUX_SESSION="bloud-dev"
2525

2626
# Colors
@@ -107,7 +107,7 @@ cmd_vm_start() {
107107
# Using access=any so VM user can read/write Mac-owned files
108108
# Using cache=none to avoid stale metadata (important for hot reload)
109109
log "Mounting shared directories..."
110-
vm_exec "sudo mount -t 9p -o trans=virtio,version=9p2000.L,msize=131072,cache=none,access=any mount0 /home/bloud.linux/bloud-v3 2>/dev/null || true"
110+
vm_exec "sudo mount -t 9p -o trans=virtio,version=9p2000.L,msize=131072,cache=none,access=any mount0 /home/bloud.linux/bloud 2>/dev/null || true"
111111
vm_exec "sudo mount -t 9p -o trans=virtio,version=9p2000.L,msize=131072,cache=none,access=any mount1 /tmp/lima 2>/dev/null || true"
112112

113113
echo ""

lima/nixos.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#
1313
# 3. SSH into the VM and apply our configuration:
1414
# limactl shell bloud
15-
# sudo nixos-rebuild switch --flake /home/bloud.linux/bloud-v3#vm-dev
15+
# sudo nixos-rebuild switch --flake /home/bloud.linux/bloud#vm-dev
1616
#
1717
# 4. The VM is now running with full bloud services.
1818
#
@@ -33,14 +33,14 @@ timezone: ""
3333

3434
# NixOS image (built with nixos-generators from NixOS 24.11, includes lima-init)
3535
images:
36-
- location: "~/Projects/bloud-v3/lima/imgs/nixos-24.11-lima.img"
36+
- location: "~/Projects/bloud/lima/imgs/nixos-24.11-lima.img"
3737
arch: "aarch64"
3838

3939
# Mount the project directory into the VM
4040
mounts:
4141
# Mount the bloud project (writable for development)
42-
- location: "~/Projects/bloud-v3"
43-
mountPoint: "/home/bloud.linux/bloud-v3"
42+
- location: "~/Projects/bloud"
43+
mountPoint: "/home/bloud.linux/bloud"
4444
writable: true
4545
9p:
4646
cache: "mmap"

lima/start-dev.sh

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
set -e
1212

13-
PROJECT_DIR="/home/bloud.linux/bloud-v3"
13+
PROJECT_DIR="/home/bloud.linux/bloud"
1414
LOCAL_SRC="/tmp/bloud-src"
1515
DATA_DIR="/home/bloud/.local/share/bloud" # Match NixOS module path
1616
LOCAL_NODE_MODULES="/tmp/bloud-node-modules"
@@ -58,6 +58,32 @@ fi
5858
rm -rf "$WEB_DIR/node_modules"
5959
ln -s "$LOCAL_NODE_MODULES/node_modules" "$WEB_DIR/node_modules"
6060

61+
# Fix go.mod replace paths for VM directory structure
62+
sed -i 's|=> ../../apps|=> ../apps|g' "$LOCAL_SRC/host-agent/go.mod" 2>/dev/null || true
63+
sed -i 's|=> ../services/host-agent|=> ../host-agent|g' "$LOCAL_SRC/apps/go.mod" 2>/dev/null || true
64+
65+
# Pre-build host-agent binary (required for service prestart/poststart hooks)
66+
echo "Building host-agent binary..."
67+
cd "$LOCAL_SRC/host-agent"
68+
if go build -o /tmp/host-agent ./cmd/host-agent 2>&1; then
69+
echo "Host-agent binary built at /tmp/host-agent"
70+
else
71+
echo "Warning: Failed to build host-agent, services may fail"
72+
fi
73+
74+
# Restart any failed services (in case services failed before binary existed)
75+
echo "Checking for failed services..."
76+
systemctl --user reset-failed 2>/dev/null || true
77+
for svc in podman-apps-postgres podman-apps-redis bloud-db-init authentik-db-init podman-apps-authentik-server podman-apps-authentik-worker podman-apps-authentik-proxy; do
78+
if systemctl --user is-failed "$svc.service" 2>/dev/null; then
79+
echo "Restarting failed service: $svc"
80+
systemctl --user restart "$svc.service" 2>/dev/null || true
81+
elif ! systemctl --user is-active "$svc.service" 2>/dev/null; then
82+
echo "Starting inactive service: $svc"
83+
systemctl --user start "$svc.service" 2>/dev/null || true
84+
fi
85+
done
86+
6187
# Create Go watch script with rsync
6288
GO_WATCH="/tmp/go-watch.sh"
6389
cat > "$GO_WATCH" << 'GO_EOF'

0 commit comments

Comments
 (0)