flake templates for projects
nix
  • Nix 95.4%
  • Shell 3.5%
  • Just 1.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Simon Gate 02f55e5e94
All checks were successful
build / check (push) Successful in 28s
build / build-templates (go) (push) Successful in 1m49s
build / build-templates (readly) (push) Successful in 9s
build / build-templates (terraform) (push) Successful in 5s
update dependencies
2026-10-28 13:52:50 +01:00
.forgejo/workflows add formatter and development shell checks 2026-10-14 15:54:07 +02:00
checks improve development package lookup errors 2026-10-14 15:54:07 +02:00
templates/dev restore terraform development template 2026-10-14 15:54:07 +02:00
.envrc add .envrc and default devShell 2026-10-14 15:54:07 +02:00
cache-check.sh create flake module (#2) 2026-10-06 11:58:42 +02:00
flake.lock update dependencies 2026-10-28 13:52:50 +01:00
flake.nix improve development package lookup errors 2026-10-14 15:54:07 +02:00
justfile add .envrc and default devShell 2026-10-14 15:54:07 +02:00
README.md improve development package lookup errors 2026-10-14 15:54:07 +02:00

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