From 67d13d8634004e884caaffe53153a6a7170168a5 Mon Sep 17 00:00:00 2001 From: EatThePooh Date: Tue, 14 Oct 2025 12:41:15 +0700 Subject: [PATCH] wrap loom into a Nix package --- flake.lock | 6 +++--- flake.nix | 6 ++++-- platform/default.nix | 31 +++++++++++++++++++++++++++++++ platform/loom/deno.json | 2 +- platform/loom/deno.lock | 38 +++++++++++++++++++------------------- platform/placeholder.txt | 1 - 6 files changed, 58 insertions(+), 26 deletions(-) create mode 100644 platform/default.nix delete mode 100644 platform/placeholder.txt diff --git a/flake.lock b/flake.lock index 87a5bcb..db5e677 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "deno-with-packages": { "locked": { - "lastModified": 1757917630, - "narHash": "sha256-zK0p0oq7NhBUUsfcPYS+iu2A0+HzzHJ4WxZ5MDd+Lis=", + "lastModified": 1759993728, + "narHash": "sha256-qZNehYgtNCB7YpMqZww4kgjlWDTPxqxivaHuCxMrGtA=", "owner": "voleum-org", "repo": "deno-with-packages", - "rev": "26f60eb96b0d092373e4fbe0ceae1a080b8f00b6", + "rev": "6af05b2c5104339767126fa968ce9c62ec9ee352", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 15cf067..2451ab5 100644 --- a/flake.nix +++ b/flake.nix @@ -19,7 +19,7 @@ shelf = import ./shelf { inherit pkgs system lib; }; - in { + in rec { deno = { enable = true; lockfiles = shelf.lockfiles ++ [ ./platform/loom/deno.lock ]; @@ -28,8 +28,10 @@ packages.website = import ./nix/website.nix { inherit pkgs; root = ./.; }; + packages.loom = import ./platform { inherit pkgs; denoCache = config.packages.deno-cache; }; + devShells.default = pkgs.mkShell { - buildInputs = with pkgs; [ config.packages.deno pandoc reuse ]; + buildInputs = with pkgs; [ config.packages.deno pandoc reuse packages.loom ]; inputsFrom = [ config.flake-root.devShell ]; shellHook = '' echo "Available scrolls:" diff --git a/platform/default.nix b/platform/default.nix new file mode 100644 index 0000000..c667c50 --- /dev/null +++ b/platform/default.nix @@ -0,0 +1,31 @@ +{ pkgs, denoCache }: +pkgs.stdenv.mkDerivation { + name = "loom"; + src = ./loom; + + buildPhase = '' + export DENO_DIR=$TMPDIR/.deno_cache + echo "Deno cache is ${denoCache}" + cp -rL "${denoCache}" "$DENO_DIR"/ 2>/dev/null || true + chmod -R u+w "$DENO_DIR" 2>/dev/null || true + + echo "DENO_DIR is $DENO_DIR" + + ${pkgs.deno}/bin/deno task build:editor + ''; + + installPhase = '' + mkdir -p $out/bin $out/editor + + cp -r editor/dist $out/editor/dist + cp -r mod.ts deno.json deno.lock $out + cp -r cli $out + # This is meant to be executed from inside a devShell with Deno set up + cat > $out/bin/loom <