Pure-eval Nix builders for Cargo, Buck2, Ninja, Deno and Starlark
Something went wrong. Try again.
README.md
nix-lib-deno #
Nix builder for Deno projects with npm dependencies. Parses deno.lock at evaluation time to create individual fetchurl derivations per npm package, so no manual hash maintenance is needed.
How it works #
fetchDenoDeps.nixreadsdeno.lockviabuiltins.fromJSON, extracts every npm entry, and fetches each tarball withfetchurlusing the integrity hash from the lock file.- The fetched tarballs are assembled into a DENO_DIR-compatible cache layout (
npm/registry.npmjs.org/<package>/<version>/) with generatedregistry.jsonmetadata files. buildDenoProject.nixuses this cache to rundeno install --frozenin the Nix sandbox, then executes the provided build command.
Usage #
buildDenoProject is exposed as lib.buildDenoProject in pkgs via the perSystemLib workspace module.
In a workspace package definition:
packages.my-app = { lib, ... }:
lib.buildDenoProject {
pname = "my-app";
src = ./.;
buildCommand = "deno run -A npm:@rsbuild/core build";
installPhase = "cp -r dist $out";
};
Parameters #
| Parameter | Default | Description |
|---|---|---|
src |
required | Source directory containing deno.lock |
buildCommand |
required | Shell command to build the project |
installPhase |
required | Shell commands to install build output to $out |
pname |
"deno-project" |
Package name |
version |
"0.0.0" |
Package version |
lockFile |
src + "/deno.lock" |
Path to the Deno lock file |
nativeBuildInputs |
[] |
Additional build inputs |
meta |
{} |
Nixpkgs meta attributes |
Files #
default.nix— workspace module exposingbuildDenoProjectviaperSystemLibbuildDenoProject.nix— Project builder derivationfetchDenoDeps.nix— npm dependency fetcher using dynamic derivations fromdeno.lock