about summary refs log tree commit diff stats
path: root/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix42
1 files changed, 41 insertions, 1 deletions
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
+  '';
 }