all repos — homestead @ b4baf9e031486e0a6374551344a088a7c3073087

Code for my website

enable building via default.nix

Alan Pearce
commit

b4baf9e031486e0a6374551344a088a7c3073087

parent

e7cc87d65799deb3846ac01ec78424b6d2141da3

1 file changed, 41 insertions(+), 1 deletion(-)

jump to
M default.nixdefault.nix
@@ -7,8 +7,15 @@ (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 = {
@@ -30,4 +37,37 @@ 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 + ''; }