1
0
Fork 0

install fennel from source as a package

nixos lua packaging is giving me a headache
This commit is contained in:
Daniel Barlow 2023-07-04 22:56:17 +01:00
parent 41687e916d
commit 24befe6bf7
3 changed files with 40 additions and 24 deletions

View File

@ -56,4 +56,5 @@
firewallgen = callPackage ./firewallgen {}; firewallgen = callPackage ./firewallgen {};
kernel-modules = callPackage ./kernel-modules {}; kernel-modules = callPackage ./kernel-modules {};
odhcp-script = callPackage ./odhcp-script {}; odhcp-script = callPackage ./odhcp-script {};
fennel = callPackage ./fennel {};
} }

19
pkgs/fennel/default.nix Normal file
View File

@ -0,0 +1,19 @@
{
stdenv
, lua
, fetchFromSourcehut
}:
let pname = "fennel";
in stdenv.mkDerivation {
inherit pname;
version = "1.3";
nativeBuildInputs = [ lua ]; # used in build
buildInputs = [ lua ]; # needed for patchShebangs
src = fetchFromSourcehut {
owner = "~technomancy";
repo = pname;
rev = "1.3.0";
hash = "sha256-DXJOdYzfjTncqL7BsDbdvZcauDMkZV2X0U0FfhfwQrw=";
};
makeFlags = [ "PREFIX=${placeholder "out"}" ];
}

View File

@ -1,31 +1,27 @@
{ {
runCommand lua
, lua
, runtimeShell
, fetchurl
, lib , lib
, lua53Packages , fennel
, stdenv
}: }:
let inherit (lua53Packages) lua; name : packages : source :
in name : packages : source :
let let
fennel = fetchurl {
url = "https://fennel-lang.org/downloads/fennel-1.3.0";
hash = "sha256-hYSD3rBYF8iTjBOA1m+TvUu8BSp8q6uIMUXi0xwo/dU=";
};
luapath = builtins.map (f: "${f}/share/lua/${lua.luaversion}/?.lua;") packages; luapath = builtins.map (f: "${f}/share/lua/${lua.luaversion}/?.lua;") packages;
luacpath = builtins.map (f: "${f}/lib/lua/${lua.luaversion}/?.so;") packages; luacpath = builtins.map (f: "${f}/lib/lua/${lua.luaversion}/?.so;") packages;
in runCommand name { in stdenv.mkDerivation {
nativeBuildInputs = [ lua ]; inherit name;
} '' src = ./.;
echo $PATH nativeBuildInputs = [ fennel ];
#!${runtimeShell} buildPhase = ''
( (
echo "#!${lua}/bin/lua" echo "#!${lua}/bin/lua"
echo "package.path = ${lib.strings.escapeShellArg luapath} .. package.path" echo "package.path = ${lib.strings.escapeShellArg luapath} .. package.path"
echo "package.cpath = ${lib.strings.escapeShellArg luacpath} .. package.cpath" echo "package.cpath = ${lib.strings.escapeShellArg luacpath} .. package.cpath"
lua ${fennel} --correlate --compile ${source} fennel --correlate --compile ${source}
) > $out ) > ${name}.lua
chmod a+x $out '';
'' installPhase = ''
cp ${name}.lua $out
chmod +x $out
'';
}