From efb536d6657567e5bc4e0c966a6378f1082e1443 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sat, 22 Jun 2024 15:11:03 +0200 Subject: enable building via default.nix --- default.nix | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/default.nix b/default.nix index fd92a90..b05d12e 100644 --- a/default.nix +++ b/default.nix @@ -7,8 +7,15 @@ let ]; }; 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 @@ in }; }; }; + 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 + ''; } -- cgit 1.4.1