Commit graph

230 commits

Author SHA1 Message Date
Doron Behar
decc06ee75
linkNodeModulesHook: respect NODE_PATH (#493427) 2026-02-25 17:41:43 +00:00
Linus Heckemann
345c0e2851 linkNodeModulesHook: respect NODE_PATH 2026-02-23 19:04:59 +01:00
nixpkgs-ci[bot]
ae20412acf
Merge master into staging-next 2026-02-16 18:12:30 +00:00
Philip Taron
4fdfb71850
build-support/node/fetch-yarn-deps: move env variables into env (#487962) 2026-02-16 16:26:08 +00:00
jopejoe1
58c1ec779f treewide: replace lib.trivial.version with lib.trivial.release 2026-02-16 09:45:06 +01:00
Jörg Thalheim
203662a570 prefetch-npm-deps: strip volatile fields from dist objects in packuments
The dist object in npm packuments contains fields that can change
after a package is published, causing hash mismatches in
fixed-output derivations:

  - signatures: changes when npm rotates registry signing keys
    (old key SHA256:jl3bwswu80Pjj... expired 2025-01-29)
  - npm-signature: legacy format being progressively removed
  - attestations: provenance metadata added post-publication

Only keep the three fields npm actually needs during install:
tarball, integrity, and shasum. Also strip the informational-only
fileCount and unpackedSize fields.

This is the same approach already used for top-level and
version-level field whitelisting.

Ref: https://github.com/numtide/llm-agents.nix/issues/2459
2026-02-15 18:09:32 +01:00
K900
15a6983bd3 Merge remote-tracking branch 'origin/master' into staging-next 2026-02-11 21:30:26 +03:00
Doron Behar
f5c43ee489 yarnConfigHook: revert "prevent yarn from resolving dependencies using git"
This reverts commit 366191a9d1. Due to
regressions reported & discussed here:

- https://github.com/NixOS/nixpkgs/pull/488109#issuecomment-3877185185
- https://github.com/NixOS/nixpkgs/pull/489040
2026-02-11 15:29:08 +02:00
nixpkgs-ci[bot]
83741d677f
Merge master into staging-next 2026-02-09 12:17:08 +00:00
Doron Behar
366191a9d1 yarnConfigHook: prevent yarn from resolving dependencies using git
Fixes #483500. Tested with the following:

```diff
diff --git i/pkgs/by-name/gr/graphest/package.nix w/pkgs/by-name/gr/graphest/package.nix
index 2c6093b385d2..d8f54103a8fc 100644
--- i/pkgs/by-name/gr/graphest/package.nix
+++ w/pkgs/by-name/gr/graphest/package.nix
@@ -23,14 +23,13 @@

 stdenv.mkDerivation (finalAttrs: {
   pname = "graphest";
-  # 1.8.2 cannot build due to https://github.com/NixOS/nixpkgs/issues/483500
-  version = "1.8.2-unstable-2026-01-21";
+  version = "1.8.2";

   src = fetchFromGitHub {
     owner = "unageek";
     repo = "graphest";
-    rev = "2bcb478acd40a1174606e51f4affeca56446c9f6";
-    hash = "sha256-+onb21xb8nhEKIL/B8sNufWaPVhABnpU3uIyRn4ISWQ=";
+    tag = "v${finalAttrs.version}";
+    hash = "sha256-cFcakTi2SRogz3pge4gxhfowjNwhS1G3QT32N7MFIdw=";
   };

   patches = [
@@ -65,7 +64,7 @@ stdenv.mkDerivation (finalAttrs: {

   yarnOfflineCache = fetchYarnDeps {
     yarnLock = finalAttrs.src + "/yarn.lock";
-    hash = "sha256-krpJflsoUPIzhdtyQu3WmapM4C63adwOq2Q6inUa3Xk=";
+    hash = "sha256-3lh1yx2wJyYKkSGx1zMzHBdAZzMj+k0VcKBa4Mf8DAU=";
   };
   env.ELECTRON_SKIP_BINARY_DOWNLOAD = 1;

```
2026-02-08 01:00:31 +02:00
Stefan Frijters
a048e93a8f
build-support/node/fetch-yarn-deps: move env variables into env 2026-02-07 14:22:22 +01:00
K900
a146c68c7e Merge remote-tracking branch 'origin/staging-next' into staging 2026-02-04 10:09:04 +03:00
Sigmanificient
f211cad9d9 fixup-yarn-lock: set pname and version 2026-02-04 00:55:33 +01:00
Sigmanificient
f1c064f1c2 prefetch-yarn-deps: set pname and version 2026-02-04 00:55:20 +01:00
Jörg Thalheim
e11702f1f1 prefetch-npm-deps: exclude deprecated field from packument whitelist
The 'deprecated' field can be modified by package maintainers at any time
via 'npm deprecate', even for already-published versions. This causes
hash mismatches when the npm registry adds deprecation notices to packages
that were previously not deprecated.

For lockfile-based installs, the version is already resolved, so the
deprecation hint used by npm-pick-manifest for version selection is not
needed. The only behavioral change is that users won't see deprecation
warnings during 'npm install', which is an acceptable tradeoff for
reproducible builds.

This was discovered when tar@7.5.2 was deprecated upstream, breaking
builds in downstream projects using fetcherVersion=2.
2026-01-20 09:11:24 +01:00
Philip Taron
963873d175
prefetch-npm-deps: add cacheVersion for packument support (#470517) 2026-01-19 15:38:43 +00:00
nixpkgs-ci[bot]
6b916b492a
Merge master into staging-next 2026-01-15 10:01:58 +00:00
Jörg Thalheim
08e805c550 prefetch-npm-deps: normalize packuments using whitelist approach
Switch from stripping known volatile fields to using an explicit whitelist
of allowed fields. This is more robust against upstream changes that add
new fields which could affect hash stability.

Top-level: only name and versions (dist-tags and time not needed for
lockfile installs where versions are already resolved)

Version-level: identity, all dependency types, dist, bin, platform
constraints (engines/os/cpu), scripts, and deprecated flag.

Based on analysis of pacote, npm-pick-manifest, npm-install-checks, and
arborist - only fields actually read during npm install are included.
2026-01-11 21:20:39 +01:00
Gutyina Gergő
34398d3276
pnpm_10: 10.26.1 -> 10.28.0 2026-01-10 12:00:35 +01:00
Jörg Thalheim
dbc8a3bc5c prefetch-npm-deps: normalize packuments for deterministic hashes
Fixed-output derivations for npm dependencies fail with hash mismatches
when rebuilt on different days. The root cause is that npm registry
metadata (packuments) contain volatile fields that change whenever
upstream publishes a new version.

For example, the TypeScript packument changes daily due to nightly
releases, even though the lockfile pins a specific version. The cached
packument includes _rev, time, modified, and the full versions list -
all of which drift over time.

Strip these volatile fields and filter the versions map to only include
versions actually referenced in the lockfile.

Signed-off-by: Jörg Thalheim <joerg@thalheim.io>
2026-01-04 13:57:43 +00:00
Jörg Thalheim
ab89ffc4b1 fetchNpmDeps: rename cacheVersion to fetcherVersion
To align with pnpm tooling.
2026-01-03 18:45:33 +00:00
Jörg Thalheim
0cb5de2d62 prefetch-npm-deps: use package name field for aliases
npm lockfiles can contain package aliases where the lockfile key differs
from the actual package name (e.g., "string-width-cjs" aliasing
"string-width"). Previously we always used the lockfile key, causing us
to fetch packuments for the wrong package.

Use the package's own "name" field when present, falling back to the
lockfile key. This ensures we fetch the correct packument for aliased
packages, fixing non-deterministic builds where the wrong packument
fetch could succeed or fail depending on network timing.
2025-12-31 07:53:32 +00:00
Jörg Thalheim
40f1b80ac7 prefetch-npm-deps: clarify backwards compatibility comment 2025-12-31 06:57:27 +00:00
Jörg Thalheim
3fb4fe294b prefetch-npm-deps: extract package names from lockfile keys
The current approach parses tarball URLs to extract package names for
packument fetching. This is fragile as it only handles npmjs.org URLs
and requires special-casing other registries.

Use lockfile keys directly instead. The lockfile already contains the
canonical package names in the form "node_modules/@scope/name", so we
can simply strip the prefix rather than parsing URLs.

This handles all registries uniformly and eliminates the URL parsing
code along with its tests.
2025-12-31 06:37:24 +00:00
Winter
d028ea9cd8 npmConfigHook: suggest cache v2 when npm install fails 2025-12-31 00:37:52 -05:00
Winter
f297c444c2 npmConfigHook: always make cache writable when using cache v2 2025-12-31 00:37:52 -05:00
Winter
0b66fed9d7 buildNpmPackage: add diagnostic for cache version mismatch 2025-12-31 00:37:52 -05:00
Jörg Thalheim
5c99ffcb8e prefetch-npm-deps: add cacheVersion for packument support
Add a cacheVersion parameter to fetchNpmDeps and npmDepsCacheVersion to
buildNpmPackage. When set to 2, prefetch-npm-deps will also fetch and
cache packuments (package metadata) in addition to tarballs.

npm can request packuments with two different Accept headers:
- corgiDoc: abbreviated metadata (default)
- fullDoc: full metadata (used for workspaces)

npm's cache policy requires headers to match, so we cache both versions.

This is opt-in via cacheVersion to avoid breaking existing hashes.
Set npmDepsCacheVersion = 2 for projects using npm workspaces.

Also fix cacache index format to properly separate multiple entries
with newlines, and update map_cache() to parse multi-line index files.
2025-12-31 00:37:52 -05:00
Jonathan Davies
22526da87d
prefetch-npm-deps: Enable full LTO 2025-12-19 21:53:26 +00:00
Jonathan Davies
bb37dfe300
prefetch-npm-deps: Bump edition to 2024 and apply cargo clippy and rustfmt fixes 2025-12-19 21:53:22 +00:00
Jonathan Davies
1cfd281c2c
prefetch-npm-deps: Run cargo update 2025-12-19 21:53:21 +00:00
Jonathan Davies
ca4684c9a3
prefetch-npm-deps: Fix isahc default-features 2024 warning 2025-12-19 21:53:13 +00:00
Jonathan Davies
ff1906466c
prefetch-npm-deps: Rename directory to match name 2025-12-19 21:53:02 +00:00
Sefa Eyeoglu
63cdea5359
fetchPnpmDeps: allow passing existing derivation args
Previously, users had to add hacks to add additional nativeBuildInputs
entries to the fetcher. This way we allow users to append
nativeBuildInputs, impureEnvVars and also merge potential passthru
attributes.

This might cause rebuilds.

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
2025-12-18 12:24:09 +01:00
Sefa Eyeoglu
65b04e5fb8
treewide: migrate to fetchPnpmDeps and pnpmConfigHook
This moves all packages to the new top-level attributes introduced
previously.

This doesn't cause any rebuilds.

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
2025-12-18 12:24:09 +01:00
Sefa Eyeoglu
d925565179
fetchPnpmDeps,pnpmConfigHook: move to top-level attribute
move pnpm.{fetchDeps,configHook} to fetchPnpmDeps and pnpmConfigHook
respectively. Also adds aliases to the former package-level attributes.

Additionally, pnpmConfigHook does not propagate pnpm anymore, to make
changing pnpm versions easier.

This brings pnpm in line with the other Node.js/JavaScript tooling in
nixpkgs.

This doesn't cause any rebuilds.

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
2025-12-17 23:43:59 +01:00
Ihar Hrachyshka
567e8dfd8e
treewide: clean up 'meta = with' pattern
This commit was created by a combination of scripts and tools:
- an ast-grep script to prefix things in meta with `lib.`,
- a modified nixf-diagnose / nixf combination to remove unused `with
lib;`, and
- regular nixfmt.

Co-authored-by: Wolfgang Walther <walther@technowledgy.de>
2025-12-10 18:09:49 +01:00
dish
86fb272649 yarnInstallHook: add meta.description
Makes search.nixos.org give the correct location for the package and
also helps users better understand it
2025-11-24 12:14:54 -05:00
Antoine du Hamel
5b74cebfbc
prefetch-npm-deps: add support for npm-shrinkwrap.json 2025-11-09 16:27:54 +01:00
Alexander Bantyev
c3a465a6de
config: add npmRegistryOverrides option
Adds npmRegistryOverrides, to be passed through to `fetchNpmDeps`.
2025-10-17 15:19:57 +04:00
Alexander Bantyev
ac3eccd296
fetchNpmDeps: add an npmRegistryOverrides argument
Adds an `npmRegistryOverrides` argument & variable to fetchNpmDeps
& prefetch-npm-deps. This is similar in usage to `url.<url>.insteadOf`
in `.gitconfig`, allowing one to redirect requests to a registry to
another URL.
2025-10-17 15:19:56 +04:00
nixpkgs-ci[bot]
e23d356469
Merge staging-next into staging 2025-10-05 00:18:23 +00:00
NAHO
c8d4dabc43
pkgs: remove optional builtins prefixes from prelude functions
Remove optional builtins prefixes from prelude functions by running:

    builtins=(
      abort
      baseNameOf
      break
      derivation
      derivationStrict
      dirOf
      false
      fetchGit
      fetchMercurial
      fetchTarball
      fetchTree
      fromTOML
      import
      isNull
      map
      null
      placeholder
      removeAttrs
      scopedImport
      throw
      toString
      true
    )

    fd \
      --type file \
      . \
      pkgs \
      --exec-batch sed --in-place --regexp-extended "
        s/\<builtins\.($(
          printf '%s\n' "${builtins[@]}" |
            paste --delimiter '|' --serial -
        ))\>/\1/g
      "

    nix fmt
2025-10-04 19:02:37 +02:00
Antoine du Hamel
3ef36b4fd0
buildNpmPackage: add support for npm-shrinkwrap.json 2025-09-22 17:50:12 +02:00
K900
8eb75c9e73 Merge remote-tracking branch 'origin/master' into staging-next 2025-08-18 15:14:49 +03:00
Alexander Sieg
2323653633
fetch-yarn-deps: follow relative redirects 2025-08-11 18:02:56 +02:00
Wolfgang Walther
90604d95bc
Merge branch 'staging-next' into staging 2025-07-24 14:33:09 +02:00
Wolfgang Walther
5a0711127c
treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
nixpkgs-ci[bot]
a506444d89
Merge staging-next into staging 2025-07-23 18:05:43 +00:00
Philip Taron
c98749388a
importNpmLock: fix native dependencies for Darwin (#423199) 2025-07-23 08:01:57 -07:00