certifix/package.nix

48 lines
1.2 KiB
Nix

{
fetchpatch,
lib,
lua5_3,
makeWrapper,
openssl,
stdenv,
}:
let
pname = "certifix";
luaossl' = lua5_3.pkgs.luaossl.overrideAttrs (o: {
patches = [
(fetchpatch {
url = "https://patch-diff.githubusercontent.com/raw/wahern/luaossl/pull/218.patch";
hash = "sha256-0+5OR9t7nw8lPi7jcM/RwI8Qt8HeXwU1jvl+f+B5V38=";
})
] ++ lib.optionals (o ? patches) o.patches;
});
http = lua5_3.pkgs.http.override { luaossl = luaossl'; };
lua = lua5_3.withPackages (ps: [
http
ps.luaposix
]);
inherit makeWrapper;
inherit (lua.pkgs) fennel;
in stdenv.mkDerivation {
inherit pname;
version = "0.1";
src = ./.;
makeFlags = [ "TARGET=${placeholder "out"}" ];
postInstall = ''
lua_path="`lua -e 'print(package.path)'`"
lua_cpath="`lua -e 'print(package.cpath)'`"
makeWrapper ${fennel}/bin/fennel \
$out/bin/${pname} \
--add-flags "--add-fennel-path $out/lib/?.fnl" \
--add-flags "--add-package-path '$out/lib/?.lua$lua_path'" \
--add-flags "--add-package-cpath '$out/lib/?.lua$lua_cpath'" \
--add-flags "$out/lib/main.fnl"
'';
buildInputs = [lua fennel];
nativeBuildInputs = [ makeWrapper ];
}