diff --git a/pkgs/default.nix b/pkgs/default.nix index 10329ee..07b20c2 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -56,4 +56,5 @@ firewallgen = callPackage ./firewallgen {}; kernel-modules = callPackage ./kernel-modules {}; odhcp-script = callPackage ./odhcp-script {}; + fennel = callPackage ./fennel {}; } diff --git a/pkgs/fennel/default.nix b/pkgs/fennel/default.nix new file mode 100644 index 0000000..4e1424c --- /dev/null +++ b/pkgs/fennel/default.nix @@ -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"}" ]; +} diff --git a/pkgs/write-fennel-script/default.nix b/pkgs/write-fennel-script/default.nix index 6eb5445..bac4874 100644 --- a/pkgs/write-fennel-script/default.nix +++ b/pkgs/write-fennel-script/default.nix @@ -1,31 +1,27 @@ { - runCommand -, lua -, runtimeShell -, fetchurl + lua , lib -, lua53Packages +, fennel +, stdenv }: -let inherit (lua53Packages) lua; -in name : packages : source : +name : packages : source : 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; luacpath = builtins.map (f: "${f}/lib/lua/${lua.luaversion}/?.so;") packages; - in runCommand name { - nativeBuildInputs = [ lua ]; - } '' - echo $PATH - #!${runtimeShell} + in stdenv.mkDerivation { + inherit name; + src = ./.; + nativeBuildInputs = [ fennel ]; + buildPhase = '' ( - echo "#!${lua}/bin/lua" - echo "package.path = ${lib.strings.escapeShellArg luapath} .. package.path" - echo "package.cpath = ${lib.strings.escapeShellArg luacpath} .. package.cpath" - lua ${fennel} --correlate --compile ${source} - ) > $out - chmod a+x $out - '' + echo "#!${lua}/bin/lua" + echo "package.path = ${lib.strings.escapeShellArg luapath} .. package.path" + echo "package.cpath = ${lib.strings.escapeShellArg luacpath} .. package.cpath" + fennel --correlate --compile ${source} + ) > ${name}.lua + ''; + installPhase = '' + cp ${name}.lua $out + chmod +x $out + ''; + }