Skip to content

Commit

Permalink
node2nix: pull in patch to fix bin scripts with crlf line-endings
Browse files Browse the repository at this point in the history
This is minor fallout from svanderburg/node2nix#302 which made node2nix
handle installing script bins itself (since npm stopped doing that
correctly).

It seems npm was doing line-ending normalization when installing these
files itself, so in addition to making all bins executable we now also
do a crlf to lf conversion on them if they are a script with a shebang.
  • Loading branch information
lilyinstarlight committed Mar 6, 2023
1 parent 10d5d61 commit 93f8b99
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions pkgs/development/node-packages/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,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/8a6ed33e026b2c3efeadf171a2dbc3e9f28ec8dc.patch";
hash = "sha256-Va8Rd9AVGm7aj61AKNIEb8zCAIKuRkWRO9koHO0lr38=";
})
];
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 93f8b99

Please sign in to comment.