wrap loom into a Nix package

This commit is contained in:
EatThePooh 2025-10-14 12:41:15 +07:00
parent 30e97f5b8e
commit 67d13d8634
6 changed files with 58 additions and 26 deletions

31
platform/default.nix Normal file
View file

@ -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 <<EOF
#!/bin/sh
cd $out
exec deno task run "\$@"
EOF
chmod +x $out/bin/loom
'';
}