aboutsummaryrefslogtreecommitdiff
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
parent02132764068aa51ac98628d988dff15255308df0 (diff)
build: package for nixHEADlatestmain
-rwxr-xr-x.gitignore2
-rw-r--r--default.nix2
-rw-r--r--flake.nix18
-rw-r--r--package.nix67
4 files changed, 89 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 8493d22..5b6abd3 100755
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,5 @@ zig-pkg/
/build/
/build-*/
/docgen_tmp/
+/result
+/result-*
diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000..068bd32
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,2 @@
+{ pkgs ? import <nixpkgs> { } }:
+pkgs.callPackage ./package.nix { }
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..a956884
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,18 @@
+{
+ description = "HTMLua HTML templating engine";
+
+ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+
+ outputs = { self, nixpkgs }:
+ let
+ systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
+ forAllSystems = nixpkgs.lib.genAttrs systems;
+ in {
+ packages = forAllSystems (system:
+ let pkgs = import nixpkgs { inherit system; };
+ in {
+ htmlua = import ./default.nix { inherit pkgs; };
+ default = self.packages.${system}.htmlua;
+ });
+ };
+}
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;
+ };
+})