fix(v1/nodejs-package-json): ensure npm < 9 is used

This commit is contained in:
DavHau 2023-06-21 17:00:17 +02:00
parent d0bc947ef4
commit a01d080fa0
3 changed files with 21 additions and 13 deletions

View File

@ -6,6 +6,11 @@
l = lib // builtins;
cfg = config.nodejs-package-json;
npm =
if l.versionOlder config.deps.npm.version "9"
then config.deps.npm
else throw "The version of config.deps.npm must be < 9";
writers = import ../../../pkgs/writers {
inherit lib;
inherit
@ -19,15 +24,6 @@
;
};
npm_8 = nodejs:
nodejs.pkgs.npm.override (old: rec {
version = "8.19.4";
src = builtins.fetchTarball {
url = "https://registry.npmjs.org/npm/-/npm-${version}.tgz";
sha256 = "0xmvjkxgfavlbm8cj3jx66mlmc20f9kqzigjqripgj71j6b2m9by";
};
});
npmArgs = l.concatStringsSep " " (map (arg: "'${arg}'") cfg.npmArgs);
in {
imports = [
@ -47,15 +43,14 @@ in {
writeScript
writeScriptBin
;
npm = npm_8 nixpkgs.nodejs;
};
lock.fields.package-lock.script =
writers.writePureShellScript
(with config.deps; [
coreutils
[
config.deps.coreutils
npm
])
]
''
source=${cfg.source}

View File

@ -21,4 +21,10 @@ in {
default = [];
};
};
options.deps = l.mapAttrs (_: l.mkOption) {
npm = {
type = t.package;
description = "The npm package used to build the lock file";
};
};
}

View File

@ -21,6 +21,13 @@
eval-cache.cacheFileRel = "/v1/nix/modules/drvs/${config.name}/cache-${system}.json";
eval-cache.repoRoot = self;
eval-cache.enable = true;
deps.npm = inputs.nixpkgsV1.legacyPackages.${system}.nodejs.pkgs.npm.override (old: rec {
version = "8.19.4";
src = builtins.fetchTarball {
url = "https://registry.npmjs.org/npm/-/npm-${version}.tgz";
sha256 = "0xmvjkxgfavlbm8cj3jx66mlmc20f9kqzigjqripgj71j6b2m9by";
};
});
};
# evalautes the package behind a given module