about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2024-06-22 15:11:03 +0200
committerAlan Pearce2024-06-22 15:11:03 +0200
commitefb536d6657567e5bc4e0c966a6378f1082e1443 (patch)
treeee4517d719295d5a40accf8ea219e974f030057c
parent024b4f78d792056a5f0c71985a520eeed7eacf88 (diff)
downloadwebsite-efb536d6657567e5bc4e0c966a6378f1082e1443.tar.lz
website-efb536d6657567e5bc4e0c966a6378f1082e1443.tar.zst
website-efb536d6657567e5bc4e0c966a6378f1082e1443.zip
enable building via 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
+  '';
 }