Skip to content

Commit

Permalink
Merge pull request #216728 from lilyinstarlight/fix/node2nix-bin-crlf
Browse files Browse the repository at this point in the history
node2nix: pull in patch to fix bin scripts with crlf line-endings
  • Loading branch information
marsam committed Mar 9, 2023
2 parents e652182 + 0835e5a commit 2e80f1e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
7 changes: 5 additions & 2 deletions pkgs/development/node-packages/node-env.nix
Original file line number Diff line number Diff line change
Expand Up @@ -530,12 +530,15 @@ let
then
ln -s $out/lib/node_modules/.bin $out/bin
# Patch the shebang lines of all the executables
# Fixup all executables
ls $out/bin/* | while read i
do
file="$(readlink -f "$i")"
chmod u+rwx "$file"
patchShebangs "$file"
if isScript "$file"
then
sed -i 's/\r$//' "$file" # convert crlf to lf
fi
done
fi
Expand Down
22 changes: 15 additions & 7 deletions pkgs/development/node-packages/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,22 @@ final: prev: {
};
nativeBuildInputs = [ pkgs.buildPackages.makeWrapper ];
postInstall = let
# Needed to fix Node.js 16+ - PR svanderburg/node2nix#302
npmPatch = fetchpatch {
name = "emit-lockfile-v2-and-fix-bin-links-with-npmv7.patch";
url = "https://github.com/svanderburg/node2nix/commit/375a055041b5ee49ca5fb3f74a58ca197c90c7d5.patch";
hash = "sha256-uVYrXptJILojeur9s2O+J/f2vyPNCaZMn1GM/NoC5n8=";
};
patches = [
# Needed to fix Node.js 16+ - PR svanderburg/node2nix#302
(fetchpatch {
name = "emit-lockfile-v2-and-fix-bin-links-with-npmv7.patch";
url = "https://github.com/svanderburg/node2nix/commit/375a055041b5ee49ca5fb3f74a58ca197c90c7d5.patch";
hash = "sha256-uVYrXptJILojeur9s2O+J/f2vyPNCaZMn1GM/NoC5n8=";
})
# Needed to fix packages with DOS line-endings after above patch - PR svanderburg/node2nix#314
(fetchpatch {
name = "convert-crlf-for-script-bin-files.patch";
url = "https://github.com/svanderburg/node2nix/commit/91aa511fe7107938b0409a02ab8c457a6de2d8ca.patch";
hash = "sha256-ISiKYkur/o8enKDzJ8mQndkkSC4yrTNlheqyH+LiXlU=";
})
];
in ''
patch -d $out/lib/node_modules/node2nix -p1 < ${npmPatch}
${lib.concatStringsSep "\n" (map (patch: "patch -d $out/lib/node_modules/node2nix -p1 < ${patch}") patches)}
wrapProgram "$out/bin/node2nix" --prefix PATH : ${lib.makeBinPath [ pkgs.nix ]}
'';
};
Expand Down

0 comments on commit 2e80f1e

Please sign in to comment.