fetchPnpmDeps: don't fail on empty lockfile

If the lockfile is empty, no files will be put in the output directory. 
In this case, the find invocations produce an empty list of results. 
xargs' default behaviour is to always invoke its command at least once; 
if its input is empty, then its command will not be passed any 
filenames. This produces an invocation like `chmod 555`. chmod, however, 
fails in this case, expecting an operand. So we need to tell xargs not 
to invoke its command at all in the case of empty input.
This commit is contained in:
Sam Pointon
2026-04-26 17:18:59 +01:00
parent af8d4b02f5
commit 37955437a7
7 changed files with 56 additions and 3 deletions
@@ -162,9 +162,9 @@ in
# See https://github.com/NixOS/nixpkgs/pull/350063
# See https://github.com/NixOS/nixpkgs/issues/422889
if [[ ${toString fetcherVersion} -ge 2 ]]; then
find $storePath -type f -name "*-exec" -print0 | xargs -0 chmod 555
find $storePath -type f -not -name "*-exec" -print0 | xargs -0 chmod 444
find $storePath -type d -print0 | xargs -0 chmod 555
find $storePath -type f -name "*-exec" -print0 | xargs --no-run-if-empty -0 chmod 555
find $storePath -type f -not -name "*-exec" -print0 | xargs --no-run-if-empty -0 chmod 444
find $storePath -type d -print0 | xargs --no-run-if-empty -0 chmod 555
fi
if [[ ${toString fetcherVersion} -ge 3 ]]; then
+2
View File
@@ -170,6 +170,8 @@ in
php = recurseIntoAttrs (callPackages ./php { });
pnpm = recurseIntoAttrs (callPackages ./pnpm { });
go = recurseIntoAttrs (callPackage ../build-support/go/tests.nix { });
lake = callPackage ../build-support/lake/test { };
+4
View File
@@ -0,0 +1,4 @@
{ callPackage }:
{
pnpm-empty-lockfile = callPackage ./pnpm-empty-lockfile { };
}
@@ -0,0 +1,32 @@
{
pkgs,
stdenv,
fetchPnpmDeps,
nodejs,
pnpm_10,
pnpmConfigHook,
}:
stdenv.mkDerivation {
name = "pnpm-empty-lockfile";
src = ./.;
nativeBuildInputs = [
pnpm_10
pnpmConfigHook
];
pnpmDeps = fetchPnpmDeps {
pname = "pnpm-empty-lockfile";
fetcherVersion = 3;
pnpm = pnpm_10;
src = ./.;
hash = "sha256-u0GOAX5B1f2ANWbOezScp/eKQRRZA/JoYfQ5zLrNip4=";
};
buildPhase = ''
runHook preBuild
touch $out
runHook postBuild
'';
}
@@ -0,0 +1,6 @@
{
"name": "pnpm-empty-lockfile",
"main": "main.mjs",
"dependencies": {
}
}
+9
View File
@@ -0,0 +1,9 @@
lockfileVersion: '9.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers:
.: {}