summary refs log tree commit diff
path: root/packages/matrix-spec.nix
diff options
context:
space:
mode:
Diffstat (limited to 'packages/matrix-spec.nix')
-rw-r--r--packages/matrix-spec.nix52
1 files changed, 52 insertions, 0 deletions
diff --git a/packages/matrix-spec.nix b/packages/matrix-spec.nix
new file mode 100644

index 0000000..01475bf --- /dev/null +++ b/packages/matrix-spec.nix
@@ -0,0 +1,52 @@ +{ + lib, + stdenv, + fetchFromGitHub, + buildGoModule, + hugo, + cacert, + + pkgs, + + matrixSpecSrc +}: +let + src = matrixSpecSrc; + + version = src.shortRev or (builtins.substring 0 7 src.dirtyRev); + rev = src.rev or src.dirtyRev; +in +buildGoModule { + inherit version; + pname = "matrix-spec"; + src = src; + vendorHash = "sha256-4f04IS76JtH+I4Xpu6gF8JQSO3TM7p56mCs8BwyPo8U="; + buildInputs = [ cacert ]; + + nativeBuildInputs = [ hugo ]; + # Nix doesn't play well with Hugo's "GitInfo" module, so disable it and inject + # the revision from the flake. + postPatch = '' +# substituteInPlace ./site/layouts/shortcodes/gitinfo.html \ +# --replace "{{ .Page.GitInfo.Hash }}" "${rev}" + +# substituteInPlace ./config/_default/config.yaml \ +# --replace "enableGitInfo: true" "enableGitInfo: false" + ${lib.getExe pkgs.lsd} -lAh . + ''; + + # Generate the Hugo site before building the Go application which embeds the + # built site. + preBuild = '' + hugo --minify --gc --cleanDestinationDir -d spec + ''; + + ldflags = [ "-X main.commit=${rev}" ]; + + # Rename the main executable in the output directory + postInstall = '' + mv $out/bin/jnsgr.uk $out/bin/jnsgruk + ''; + + meta.mainProgram = "jnsgruk"; +}