- Nix 95.4%
- Shell 3.5%
- Just 1.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo/workflows | ||
| checks | ||
| templates/dev | ||
| .envrc | ||
| cache-check.sh | ||
| flake.lock | ||
| flake.nix | ||
| justfile | ||
| README.md | ||
Nix flake templates for development
Development shells are provided by the rolling main branch. Consumer
flakes pin the selected revision in their flake.lock; run
nix flake update smgtdev to adopt changes.
Changes to the flake, checks, templates, or workflow run CI validation on pull
requests and main. CI evaluates both supported systems and runs native checks;
on main, it also builds and publishes the Go, Readly, and Terraform shells to
the readly Cachix cache on x86_64-linux.
Add the templates to your Nix registry:
nix registry add smgt git+https://git.0xee.cc/smgt/flake.git
Development
Format Nix files with nix fmt. Run nix flake check for formatting and shell
API regression checks, and nix flake check --all-systems --no-build to evaluate
both supported systems without requiring a cross-platform builder. The checks
evaluate shell derivations and the Go, Readly, and Terraform consumer templates;
CI builds the named shells separately.
Go
nix flake init -t smgt#go-dev
Readly
nix flake init -t smgt#readly-dev
The generated Go and Terraform templates use this flake's lib.eachSystem API.
Enabling Go always adds go-overlay's default tools, gotestsum, and entr; consumers
can add more tools without replacing these defaults. Terraform is disabled unless enabled;
the Readly template pins Terraform to 1.9 while the generic Terraform shell
uses the latest version exposed by its pinned input. Shells can be combined
and versions selected in the project flake:
{
inputs.smgtdev.url = "git+https://git.0xee.cc/smgt/flake.git?ref=main";
outputs = {smgtdev, ...}:
smgtdev.lib.eachSystem {
go = {
enable = true;
version = "1.27.1";
};
};
}
eachSystem returns the complete system-specific devShells output.
Go and Terraform are disabled by default. Omitting a Go version selects the
latest stable version in the pinned go-overlay. Generic Terraform shells default
to the latest version in the pinned input; the Readly template selects 1.9.
Versions must be available from the inputs pinned in the consumer's lock file.
Extra tools can be added with packages, build dependencies with buildInputs,
and shell initialization commands with shellHook. Shells are available on
x86_64-linux and aarch64-linux; CI currently builds only x86_64-linux.
Both package options accept derivations, top-level names from the pinned Nixpkgs
(for example, packages = ["jq" "git"];), or a function taking pkgs and returning
a list of either. Strings are literal top-level names; for nested packages such
as python3Packages.requests, use a function:
smgtdev.lib.eachSystem {
packages = pkgs: [pkgs.jq pkgs.python3Packages.requests];
buildInputs = pkgs: [pkgs.zlib];
};
Unknown names report the offending package and option. The same overlaid package
set is available as smgtdev.devEnv.pkgs.${system}.
If used with direnv you can add
the following to .envrc to load the dev shell automatically.
if has nix;then
use flake
fi
Ruby
nix flake init -t smgt#ruby
Terraform
nix flake init -t smgt#terraform