9f8afeffb2
* ci: not triggered on pull request * fmt * nomore flake-compat * Revert "nomore flake-compat" This reverts commit f3c85c80d2e2b9d56bd675661c9e35a0b99c656c.
55 lines
1.1 KiB
Nix
55 lines
1.1 KiB
Nix
{
|
|
pkgs,
|
|
stdenv,
|
|
deno2nix,
|
|
lib,
|
|
...
|
|
}: {
|
|
pname,
|
|
version,
|
|
src,
|
|
lockfile,
|
|
output ? "bundled.js",
|
|
outPath ? "dist",
|
|
minify ? false,
|
|
entrypoint,
|
|
importMap ? null,
|
|
additionalDenoFlags ? "",
|
|
}: let
|
|
inherit (deno2nix.internal) mkDepsLink;
|
|
in
|
|
stdenv.mkDerivation {
|
|
inherit pname version entrypoint src;
|
|
buildInputs = with pkgs; [deno jq nodePackages.uglify-js];
|
|
|
|
buildPhase = ''
|
|
export DENO_DIR="/tmp/deno2nix"
|
|
mkdir -p $DENO_DIR
|
|
ln -s "${mkDepsLink lockfile}" $(deno info --json | jq -r .modulesCache)
|
|
|
|
deno bundle \
|
|
--lock="${lockfile}" \
|
|
${
|
|
if importMap != null
|
|
then "--import-map=\"$src/${importMap}\""
|
|
else ""
|
|
} \
|
|
${additionalDenoFlags} \
|
|
"$src/${entrypoint}" \
|
|
"${output}"
|
|
|
|
${
|
|
if minify
|
|
then ''
|
|
mv ${output} ${output}-non-min
|
|
uglifyjs ${output}-non-min -c -m > ${output}
|
|
''
|
|
else ""
|
|
}
|
|
'';
|
|
installPhase = ''
|
|
mkdir -p $out/${outPath}
|
|
install -t $out/${outPath} "${output}"
|
|
'';
|
|
}
|