main
1# Makefile for building and deploying the static website
2# Pipeline: org → ox-tufte (Emacs) → soupault → rsync
3
4# Default deployment target
5DEPLOY_TARGET ?= carthage.vpn:/var/www/vincent.demeester.fr
6
7RSYNC_OPTS = -avz -e ssh --delete
8
9.PHONY: flux soupault build deploy deploy-dry-run clean help
10
11# Build the flux CLI tool
12bin/flux: cmd/flux/main.go internal/flux/*.go
13 @echo "Building flux..."
14 nix-shell -p go --run "go build -o bin/flux ./cmd/flux/"
15
16# Generate flux stream (entries + HTML + feeds + homepage snippet)
17flux: bin/flux
18 @echo "Generating flux stream..."
19 ./bin/flux generate -v
20
21# Populate site/ with content from repo root for soupault processing
22populate-site: flux
23 @echo "Populating site/ from repo root..."
24 @for d in articles posts 2022 emacs tekton kubernetes containers nixos machines docs about; do \
25 if [ -d "$$d" ]; then \
26 mkdir -p "site/$$d"; \
27 find "$$d" -name '*.html' -not -path '*/data/*' -exec sh -c 'test -f site/"{}" || cp "{}" site/"{}"' \; 2>/dev/null || true; \
28 fi; \
29 done
30 @for f in $$(find . -maxdepth 1 -name '*.html' -not -name index.html -not -name tufte.html -not -name css.html | sed 's|^\./||'); do \
31 test -f "site/$$f" || cp "$$f" site/ 2>/dev/null || true; \
32 done
33
34# Inject flux snippet into site/index.html before soupault runs
35inject-snippet: populate-site
36 @echo "Injecting flux snippet into homepage..."
37 @cp site/index.html site/index.html.bak
38 @sed -i '/<!-- FLUX_SNIPPET -->/r flux/home-snippet.html' site/index.html
39 @sed -i '/<!-- FLUX_SNIPPET -->/d' site/index.html
40
41# Run soupault to process site/ → build/
42soupault: inject-snippet
43 @echo "Running soupault..."
44 nix-shell -p soupault --run "soupault"
45 @echo "Build complete! Output in build/"
46 @# Restore the placeholder in site/index.html for next run
47 @mv site/index.html.bak site/index.html
48
49# Build: soupault + copy static assets + flux into build/
50build: soupault
51 @echo "Copying static assets to build/..."
52 @cp -rf images/ build/images/ 2>/dev/null || true
53 @cp -rf img/ build/img/ 2>/dev/null || true
54 @cp -rf articles/data/ build/articles/data/ 2>/dev/null || true
55 @cp -rf articles/images/ build/articles/images/ 2>/dev/null || true
56 @mkdir -p build/articles
57 @cp -f articles/foo.gif build/articles/ 2>/dev/null || true
58 @cp -rf assets/ build/assets/ 2>/dev/null || true
59 @cp -rf css/fonts/ build/css/fonts/ 2>/dev/null || true
60 @cp -f style.css build/style.css
61 @cp -f flux.js build/flux.js
62 @cp -f index.xml build/index.xml 2>/dev/null || true
63 @echo "Copying flux output to build/flux/..."
64 @mkdir -p build/flux/tags
65 @cp -f flux/index.html flux/feed.json flux/feed.xml flux/content.json flux/content.xml build/flux/ 2>/dev/null || true
66 @cp -f flux/2*.html build/flux/ 2>/dev/null || true
67 @cp -f flux/tags/*.html build/flux/tags/ 2>/dev/null || true
68
69# Deploy: rsync build/ as the site root
70deploy: build
71 @echo "Deploying to $(DEPLOY_TARGET)..."
72 rsync $(RSYNC_OPTS) build/ $(DEPLOY_TARGET)/
73 @echo "Deployment complete!"
74
75# Dry-run deploy
76deploy-dry-run: build
77 @echo "Dry run deployment to $(DEPLOY_TARGET)..."
78 rsync $(RSYNC_OPTS) --dry-run build/ $(DEPLOY_TARGET)/
79
80# Clean build artifacts
81clean:
82 rm -rf build .soupault-cache
83
84help:
85 @echo "Available targets:"
86 @echo " soupault - Run soupault (site/ → build/)"
87 @echo " build - Run soupault + static assets + flux → build/"
88 @echo " deploy - Build + deploy to target server"
89 @echo " deploy-dry-run - Build + show what would be deployed"
90 @echo " clean - Remove build artifacts"
91 @echo " help - Show this help message"
92 @echo ""
93 @echo "Variables:"
94 @echo " DEPLOY_TARGET - Deployment destination (default: $(DEPLOY_TARGET))"
95 @echo ""
96 @echo "Pipeline:"
97 @echo " 1. Export org files via ox-tufte (Emacs) → site/"
98 @echo " 2. make build → soupault + static assets + flux → build/"
99 @echo " 3. make deploy → rsync build/ to server"