2022-09-09 14:36:35 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
stdenv,
|
|
|
|
deno2nix,
|
|
|
|
...
|
|
|
|
}: {
|
2022-09-09 19:06:41 +00:00
|
|
|
pname,
|
2022-08-03 23:32:54 +00:00
|
|
|
version,
|
|
|
|
src,
|
|
|
|
lockfile,
|
2022-09-09 19:06:41 +00:00
|
|
|
output ? pname,
|
|
|
|
entrypoint,
|
2022-08-03 23:32:54 +00:00
|
|
|
importMap ? null,
|
2022-09-09 19:06:41 +00:00
|
|
|
additionalDenoFlags ? "",
|
2022-08-03 23:32:54 +00:00
|
|
|
}: let
|
2022-09-09 14:36:35 +00:00
|
|
|
inherit (deno2nix.internal) mkDepsLink;
|
2022-08-03 23:32:54 +00:00
|
|
|
in
|
2022-09-09 14:36:35 +00:00
|
|
|
stdenv.mkDerivation {
|
2022-09-09 19:06:41 +00:00
|
|
|
inherit pname version src;
|
|
|
|
dontFixup = true;
|
2022-08-03 23:32:54 +00:00
|
|
|
|
2022-09-09 19:06:41 +00:00
|
|
|
buildInputs = with pkgs; [deno jq];
|
2022-08-03 23:32:54 +00:00
|
|
|
buildPhase = ''
|
|
|
|
export DENO_DIR=`mktemp -d`
|
|
|
|
ln -s "${mkDepsLink lockfile}" $(deno info --json | jq -r .modulesCache)
|
|
|
|
|
2022-09-09 19:06:41 +00:00
|
|
|
deno compile \
|
|
|
|
--cached-only \
|
|
|
|
--lock="${lockfile}" \
|
|
|
|
--output="${output}" \
|
|
|
|
${
|
|
|
|
if importMap != null
|
|
|
|
then "--import-map=\"$src/${importMap}\""
|
|
|
|
else ""
|
|
|
|
} \
|
|
|
|
${additionalDenoFlags} \
|
|
|
|
"$src/${entrypoint}"
|
2022-08-03 23:32:54 +00:00
|
|
|
'';
|
2022-09-09 19:06:41 +00:00
|
|
|
|
2022-08-03 23:32:54 +00:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin
|
2022-09-09 19:06:41 +00:00
|
|
|
cp "${output}" "$out/bin/"
|
2022-08-03 23:32:54 +00:00
|
|
|
'';
|
|
|
|
}
|