summaryrefslogtreecommitdiff
path: root/package.nix
diff options
context:
space:
mode:
authorGrace Yoder <grace_yoder@outlook.com>2026-09-10 12:13:32 -0400
committerGrace Yoder <grace_yoder@outlook.com>2026-09-14 12:51:51 -0400
commitff15618469488db5dd6f4d932a2bdda787ce3956 (patch)
treee5ac3870fe465b04e50d0dc338878976d386e606 /package.nix
parent02132764068aa51ac98628d988dff15255308df0 (diff)
build: package for nixHEADlatestmain
Diffstat (limited to 'package.nix')
-rw-r--r--package.nix67
1 files changed, 67 insertions, 0 deletions
diff --git a/package.nix b/package.nix
new file mode 100644
index 0000000..e459172
--- /dev/null
+++ b/package.nix
@@ -0,0 +1,67 @@
+{
+ lib,
+ stdenv,
+ runCommand,
+ zig_0_16,
+ zigDepsHash ? "sha256-HWfTcAUFL4vZJDg242y5R3zQY6fDshKk6VMn+qgSNi4=",
+}:
+
+let
+ zig = zig_0_16;
+in
+stdenv.mkDerivation (finalAttrs: {
+ pname = "htmlua";
+ version = "1.0.0-alpha";
+
+ src = lib.fileset.toSource {
+ root = ./.;
+ fileset = lib.fileset.unions [
+ ./build.zig
+ ./build.zig.zon
+ ./src
+ ./examples
+ ./LICENSE
+ ./README.md
+ ];
+ };
+
+ nativeBuildInputs = [ zig ];
+
+ zigDeps =
+ runCommand "${finalAttrs.pname}-${finalAttrs.version}-zig-deps"
+ {
+ inherit (finalAttrs) src;
+ nativeBuildInputs = [ zig ];
+ outputHashMode = "recursive";
+ outputHashAlgo = "sha256";
+ outputHash = zigDepsHash;
+ }
+ ''
+ export ZIG_GLOBAL_CACHE_DIR="$TMPDIR/zig-cache"
+ mkdir -p "$ZIG_GLOBAL_CACHE_DIR/tmp"
+ runHook unpackPhase
+ cd "$sourceRoot"
+
+ for attempt in 1 2 3; do
+ if zig build --fetch; then
+ mv "$ZIG_GLOBAL_CACHE_DIR/p" "$out"
+ exit 0
+ fi
+ echo "Zig dependency fetch attempt $attempt failed" >&2
+ done
+ exit 1
+ '';
+
+ postConfigure = ''
+ ln -s ${finalAttrs.zigDeps} "$ZIG_GLOBAL_CACHE_DIR/p"
+ '';
+
+ doCheck = true;
+
+ meta = {
+ description = "An HTML templating engine with (not yet reimplemented) Lua scripting abilities";
+ license = lib.licenses.mit;
+ mainProgram = "htmlua";
+ platforms = lib.platforms.unix;
+ };
+})