From 8af4e9fd5b54a6dde7930928a42e12c4ba8908d0 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Sat, 20 Apr 2024 14:59:14 +0100 Subject: [PATCH] package anoia assert macros and point fennelrepl at them --- pkgs/anoia/Makefile | 1 - pkgs/anoia/default.nix | 7 ++++++- pkgs/anoia/test.fnl | 4 ++-- pkgs/fennelrepl/default.nix | 1 + 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pkgs/anoia/Makefile b/pkgs/anoia/Makefile index 800808e..2cf691a 100644 --- a/pkgs/anoia/Makefile +++ b/pkgs/anoia/Makefile @@ -2,7 +2,6 @@ default: fs.lua init.lua nl.lua svc.lua test: - ln -s . anoia fennel test.fnl %.lua: %.fnl diff --git a/pkgs/anoia/default.nix b/pkgs/anoia/default.nix index a0c3f88..9333e63 100644 --- a/pkgs/anoia/default.nix +++ b/pkgs/anoia/default.nix @@ -10,10 +10,15 @@ in stdenv.mkDerivation { src = ./.; nativeBuildInputs = [ fennel ]; buildInputs = with lua.pkgs; [ luafilesystem ]; + outputs = [ "out" "dev" ]; + doCheck = true; - checkPhase = "make test"; + installPhase = '' mkdir -p "$out/share/lua/${lua.luaversion}/${pname}" cp *.lua "$out/share/lua/${lua.luaversion}/${pname}" + + mkdir -p "$dev/share/lua/${lua.luaversion}/${pname}" + cp assert.fnl "$dev/share/lua/${lua.luaversion}/${pname}" ''; } diff --git a/pkgs/anoia/test.fnl b/pkgs/anoia/test.fnl index a1878ff..8a760ce 100644 --- a/pkgs/anoia/test.fnl +++ b/pkgs/anoia/test.fnl @@ -1,5 +1,5 @@ -(local { : hash : base64url } (require :anoia)) -(import-macros { : expect= } :anoia.assert) +(local { : hash : base64url } (require :init)) +(import-macros { : expect= } :assert) (expect= (hash "") 5381) diff --git a/pkgs/fennelrepl/default.nix b/pkgs/fennelrepl/default.nix index e187b11..174959a 100644 --- a/pkgs/fennelrepl/default.nix +++ b/pkgs/fennelrepl/default.nix @@ -31,6 +31,7 @@ in writeScriptBin "fennelrepl" '' package.cpath = ${lib.strings.escapeShellArg luacpath} .. ";" .. (package.cpath or "") local fennel = require "fennel" table.insert(package.loaders or package.searchers,1, fennel.searcher) + fennel['macro-path'] = "${anoia.dev}/share/lua/${lua.luaversion}/?.fnl;" .. fennel['macro-path'] local more_fennel = os.getenv("FENNEL_PATH") if more_fennel then