added test case and improved api

This commit is contained in:
aMOPel
2025-06-03 17:39:55 +02:00
parent 2335220e54
commit 02b2beed9e
6 changed files with 67 additions and 11 deletions

View File

@@ -908,8 +908,8 @@ Related options:
: The Flags passed to `deno install`.
: _Default:_ `[ "--allow-scripts" "--frozen" ]` for `buildDenoDeps`
: _Default:_ `[ "--allow-scripts" "--frozen" "--cached-only" ]` for `buildDenoPackage`
: _Default:_ `[ "--allow-scripts" "--frozen" ]` for `buildDenoDeps` (`"--cached-only"` is filtered out)
#### Private registries {#javascript-buildDenoPackage-private-registries}
There are currently 2 options, which enable the use of private registries in a `buildDenoPackage` derivation.
@@ -1017,7 +1017,11 @@ Related options:
*`denoCompileFlags`* (Array of string; optional)
: Flags passed to `deno compile`.
: Flags passed to `deno compile [denoTaskFlags] ${binaryEntrypointPath} [extraCompileFlags]`.
*`extraCompileFlags`* (Array of string; optional)
: Flags passed to `deno compile [denoTaskFlags] ${binaryEntrypointPath} [extraCompileFlags]`.
*`binaryEntrypointPath`* (String or null; optional)
@@ -1093,7 +1097,11 @@ Related options:
*`denoTaskFlags`* (Array of strings; optional)
: The flags passed to `deno task`.
: The flags passed to `deno task [denoTaskFlags] ${denoTaskScript} [extraTaskFlags]`.
*`extraTaskFlags`* (Array of strings; optional)
: The flags passed to `deno task [denoTaskFlags] ${denoTaskScript} [extraTaskFlags]`.
*`denoTaskPrefix`* (String; optional)

View File

@@ -65,16 +65,20 @@
binaryEntrypointPath ? null,
# Flags to pass to all deno commands.
denoFlags ? [ ],
# Flags to pass to `deno task ${denoTaskScript}`.
# Flags to pass to `deno task [denoTaskFlags] ${denoTaskScript}`.
denoTaskFlags ? [ ],
# Flags to pass to `deno compile`.
# Flags to pass to `deno compile [denoTaskFlags] ${binaryEntrypointPath}`.
denoCompileFlags ? [ ],
# Flags to pass to `deno install`.
# Flags to pass to `deno install [denoInstallFlags]`.
denoInstallFlags ? [
"--allow-scripts"
"--frozen"
"--cached-only"
],
# Flags to pass to `deno task [denoTaskFlags] ${denoTaskScript} [extraTaskFlags]`.
extraTaskFlags ? [ ],
# Flags to pass to `deno compile [denoTaskFlags] ${binaryEntrypointPath} [extraCompileFlags]`.
extraCompileFlags ? [ ],
nativeBuildInputs ? [ ],
dontFixup ? true,
# Custom denoConfigHook
@@ -98,6 +102,8 @@ let
denoTaskFlags_ = builtins.concatStringsSep " " denoTaskFlags;
denoCompileFlags_ = builtins.concatStringsSep " " denoCompileFlags;
denoInstallFlags_ = builtins.concatStringsSep " " denoInstallFlags;
extraTaskFlags_ = builtins.concatStringsSep " " extraTaskFlags;
extraCompileFlags_ = builtins.concatStringsSep " " extraCompileFlags;
args' = builtins.removeAttrs args [ "denoDepsInjectedEnvVars" ];
@@ -133,6 +139,8 @@ stdenvNoCC.mkDerivation (
denoTaskFlags_
denoCompileFlags_
denoInstallFlags_
extraTaskFlags_
extraCompileFlags_
binaryEntrypointPath
hostPlatform_
denoWorkspacePath

View File

@@ -16,12 +16,20 @@ denoBuildHook() {
deno compile \
--output "$package_name" \
--target "$hostPlatform_" \
"${denoWorkspacePath+$denoWorkspacePath/}$binaryEntrypointPath" \
$denoCompileFlags \
$denoFlags
$denoFlags \
"${denoWorkspacePath+$denoWorkspacePath/}$binaryEntrypointPath"
$extraCompileFlags \
elif [ -n "${denoTaskScript-}" ]; then
if ! @denoTaskPrefix@ deno task ${denoWorkspacePath+--cwd=$denoWorkspacePath} "$denoTaskScript" $denoTaskFlags $denoFlags @denoTaskSuffix@; then
if ! @denoTaskPrefix@ \
deno task \
${denoWorkspacePath+--cwd=$denoWorkspacePath} \
$denoTaskFlags \
$denoFlags \
"$denoTaskScript" \
$extraTaskFlags \
@denoTaskSuffix@; then
echo
echo 'ERROR: `deno task` failed'
echo

View File

@@ -12,5 +12,6 @@
inherit (pkgs.callPackage ./external { })
readma-cli-linux
fresh-init-cli-linux
invidious-companion-cli-linux
;
}

View File

@@ -27,4 +27,34 @@
binaryEntrypointPath = "./src/mod.ts";
targetSystem = "x86_64-linux";
};
invidious-companion-cli-linux = buildDenoPackage {
pname = "invidious-companion-cli";
version = "";
denoDepsHash = "sha256-z78m/Na2jvUARi4cTQvtFnD6iF7YX9Vzh2D6DBSj/HA=";
src = fetchFromGitHub {
owner = "iv-org";
repo = "invidious-companion";
rev = "a34c27ff63e51f9e3adc0e8647cd12382f8f1ffe";
hash = "sha256-/S8F7G8li12k0objsdFuh+mle6p2mk8zNUUCrG9hgns=";
};
binaryEntrypointPath = "src/main.ts";
denoCompileFlags = [
"--include=./src/lib/helpers/youtubePlayerReq.ts"
"--include=./src/lib/helpers/getFetchClient.ts"
"--allow-import=github.com:443,jsr.io:443,cdn.jsdelivr.net:443,esm.sh:443,deno.land:443"
"--allow-net"
"--allow-env"
"--allow-read"
"--allow-sys=hostname"
"--allow-write=/var/tmp/youtubei.js"
];
denoInstallFlags = [
"--allow-scripts"
"--frozen"
"--cached-only"
"--entrypoint"
"src/main.ts"
];
targetSystem = "x86_64-linux";
};
}

View File

@@ -6,11 +6,12 @@ rec {
denoDepsHash = "sha256-Qvn3g+2NeWpNCfmfqXtPcJU4+LwrOSh1nq51xAbZZhk=";
src = nix-gitignore.gitignoreSource [ ] ./.;
denoWorkspacePath = "./sub1";
denoTaskFlags = [
extraTaskFlags = [
"--text"
"sub1"
];
denoTaskSuffix = ">out.txt";
installPhase = ''
cp out.txt $out
'';
@@ -20,7 +21,7 @@ rec {
version = "0.1.0";
inherit (sub1) denoDeps src;
denoWorkspacePath = "./sub2";
denoTaskFlags = [
extraTaskFlags = [
"--text"
"sub2"
];