let sources = import ./npins; pkgs = import sources.nixpkgs { overlays = [ (import "${sources.gomod2nix}/overlay.nix") ]; }; pre-commit-hooks = import sources.pre-commit-hooks; inherit (pkgs) buildGoApplication lib runCommandLocal; version = "unstable"; in rec { pre-commit-check = pre-commit-hooks.run { src = ./.; hooks = { go-mod-tidy = { enable = true; name = "go-mod-tidy"; description = "Run `go mod tidy`"; types_or = [ "go" "go-mod" ]; entry = "${pkgs.go}/bin/go mod tidy"; pass_filenames = false; }; gomod2nix = { enable = true; name = "gomod2nix"; description = "Import go.mod updates to nix"; types_or = [ "go-sum" ]; entry = "${pkgs.gomod2nix}/bin/gomod2nix --outdir nix"; pass_filenames = false; }; }; }; builder = buildGoApplication { pname = "website-builder"; inherit version; CGO_ENABLED = 0; src = with lib.fileset; toSource { root = ./.; fileset = unions [ ./go.mod ./go.sum ./cmd/build ./internal ]; }; modules = ./nix/gomod2nix.toml; patchPhase = '' ${pkgs.templ}/bin/templ generate ''; subPackages = [ "cmd/build" ]; }; website = runCommandLocal "build" { src = with lib.fileset; toSource { root = ./.; fileset = unions [ ./config.toml ./content ./static ./templates ]; }; } '' ${builder}/bin/build -s $src -d $out ''; }