Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefetch-npm-deps: download dev deps for git deps with install scripts #206476

Merged
merged 5 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pkgs/build-support/node/build-npm-package/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# The output hash of the dependencies for this project.
# Can be calculated in advance with prefetch-npm-deps.
, npmDepsHash ? ""
# Whether to force the usage of Git dependencies that have install scripts, but not a lockfile.
# Use with care.
, forceGitDeps ? false
# Whether to make the cache writable prior to installing dependencies.
# Don't set this unless npm tries to write to the cache directory, as it can slow down the build.
, makeCacheWritable ? false
Expand All @@ -32,7 +35,7 @@

let
npmDeps = fetchNpmDeps {
inherit src srcs sourceRoot prePatch patches postPatch;
inherit forceGitDeps src srcs sourceRoot prePatch patches postPatch;
name = "${name}-npm-deps";
hash = npmDepsHash;
};
Expand Down
11 changes: 8 additions & 3 deletions pkgs/build-support/node/fetch-npm-deps/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
'';
};

makeTest = { name, src, hash }: testers.invalidateFetcherByDrvHash fetchNpmDeps {
inherit name hash;
makeTest = { name, src, hash, forceGitDeps ? false }: testers.invalidateFetcherByDrvHash fetchNpmDeps {
inherit name hash forceGitDeps;

src = makeTestSrc { inherit name src; };
};
Expand Down Expand Up @@ -108,6 +108,8 @@
};

hash = "sha256-+KA8/orSBJ4EhuSyQO8IKSxsN/FAsYU3lOzq+awuxNQ=";

forceGitDeps = true;
};
};

Expand All @@ -121,6 +123,7 @@
fetchNpmDeps =
{ name ? "npm-deps"
, hash ? ""
, forceGitDeps ? false
, ...
} @ args:
let
Expand All @@ -131,6 +134,8 @@
outputHash = "";
outputHashAlgo = "sha256";
};

forceGitDeps_ = lib.optionalAttrs forceGitDeps { FORCE_GIT_DEPS = true; };
in
stdenvNoCC.mkDerivation (args // {
inherit name;
Expand Down Expand Up @@ -161,5 +166,5 @@
dontInstall = true;

outputHashMode = "recursive";
} // hash_);
} // hash_ // forceGitDeps_);
}
2 changes: 1 addition & 1 deletion pkgs/build-support/node/fetch-npm-deps/src/cacache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Cache {
&mut p,
&hash
.into_iter()
.map(|x| format!("{:02x}", x))
.map(|n| format!("{n:02x}"))
.collect::<String>(),
);

Expand Down
Loading