ModulesGo
Go Module Implementation
Go application module for stackpanel.
Go application module for stackpanel.
Automatically provides tooling and packages for Go apps defined in config.stackpanel.apps with go.enable = true.
Prerequisites
- Root go.mod at repository root (monorepo/workspace style)
- Single gomod2nix.toml at root (generated via: gomod2nix generate)
- Apps are subpackages (e.g., apps/stackpanel-go)Architecture
Generated files (package.json, .air.toml, tools.go) are created as
derivations, ensuring hermetic builds with proper dependency ordering.
Files are materialized via stackpanel.files system during shell entry.Features per Go app:
- Packaged app with buildGoApplication (for distribution)
- Development environment with mkGoEnv (for go run/test/build)
- Derivation-based file generation (hermetic, can be build dependencies)
- File materialization via stackpanel.files for IDE/tooling support
- Test package for flake checksApp definition example:
stackpanel.apps.stackpanel-go = {
path = "apps/stackpanel-go"; # Path relative to repo root
go = {
enable = true;
binaryName = "stackpanel"; # Rename binary (optional)
ldflags = [ "-s" "-w" ]; # Optional linker flags
generateFiles = true; # Generate package.json, .air.toml, tools.go
};
};Generated outputs:
- packages.<name>: Built Go binary (with generated files if enabled)
- packages.<name>-dev: mkGoEnv for development
- packages.<name>-generated-files: Derivation with generated files
- checks.<name>-tests: Go testsFile Materialization:
Generated files are materialized via stackpanel.files.entries.
Use `write-files` command to manually regenerate files.
Files are automatically written on shell entry.