Building¶
This guide covers building Kartoza ZFS Backup Tool from source.
Prerequisites¶
Using Nix (Recommended)¶
With Nix installed, all dependencies are handled automatically:
Manual Setup¶
Without Nix, ensure you have:
- Go 1.21 or later
- Git
Development Shell¶
The Nix flake provides a complete development environment:
# Enter the shell
nix develop
# Available commands:
go build # Build the binary
go test # Run tests
go run . # Run directly
Building¶
Using Make¶
# Build for current platform
make build
# Run the built binary
./zfs-backup
# Clean build artifacts
make clean
# Build for all platforms
make build-all
Using Go Directly¶
# Simple build
go build -o zfs-backup .
# With version info
go build -ldflags "-X main.version=1.0.0" -o zfs-backup .
# Race detector (for testing)
go build -race -o zfs-backup .
Using Nix¶
# Build the package
nix build
# Run the built binary
./result/bin/zfs-backup
# Build and run in one step
nix run
Cross-Compilation¶
Linux (AMD64)¶
Linux (ARM64)¶
macOS (AMD64)¶
macOS (ARM64 / Apple Silicon)¶
Dependencies¶
Go Modules¶
Dependencies are managed via Go modules:
Key Dependencies¶
| Package | Purpose |
|---|---|
| github.com/charmbracelet/bubbletea | TUI framework |
| github.com/charmbracelet/bubbles | TUI components |
| github.com/charmbracelet/lipgloss | Terminal styling |
Testing¶
# Run all tests
go test ./...
# With verbose output
go test -v ./...
# With coverage
go test -cover ./...
# Generate coverage report
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
Linting¶
# Using golangci-lint (if installed)
golangci-lint run
# Using go vet
go vet ./...
# Format code
go fmt ./...
Documentation¶
Building MkDocs¶
# Install dependencies
pip install mkdocs-material mkdocs-minify-plugin
# Serve locally
mkdocs serve
# Build static site
mkdocs build
Viewing Locally¶
Release Process¶
- Update version in
main.go - Update CHANGELOG (if exists)
- Commit changes
- Tag the release:
- GitHub Actions will build and publish