Skip to content

Commit

Permalink
Apply dos2unix to script bin files
Browse files Browse the repository at this point in the history
After we started generating our own bin links, we did not provide the
line-ending normalization that npm did. This corrects that to have
similar behavior to before for packages with CRLF line-endings.
  • Loading branch information
lilyinstarlight committed Feb 16, 2023
1 parent 315e1b8 commit 090516b
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

let
nodeEnv = import ./nix/node-env.nix {
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
inherit (pkgs) stdenv lib python2 dos2unix runCommand writeTextFile writeShellScript;
inherit pkgs nodejs;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};
Expand Down
1 change: 1 addition & 0 deletions lib/expressions/CompositionExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ CompositionExpression.prototype.toNixAST = function() {
stdenv: new nijs.NixInherit("pkgs"),
lib: new nijs.NixInherit("pkgs"),
python2: new nijs.NixInherit("pkgs"),
dos2unix: new nijs.NixInherit("pkgs"),
libtool: new nijs.NixIf({
ifExpr: new nijs.NixAttrReference({
attrSetExpr: new nijs.NixExpression("pkgs"),
Expand Down
6 changes: 4 additions & 2 deletions nix/node-env.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file originates from node2nix

{lib, stdenv, nodejs, python2, pkgs, libtool, runCommand, writeTextFile, writeShellScript}:
{lib, stdenv, nodejs, python2, pkgs, dos2unix, libtool, runCommand, writeTextFile, writeShellScript}:

let
# Workaround to cope with utillinux in Nixpkgs 20.09 and util-linux in Nixpkgs master
Expand Down Expand Up @@ -498,7 +498,7 @@ let
in
stdenv.mkDerivation ({
name = "${name}${if version == null then "" else "-${version}"}";
buildInputs = [ tarWrapper python nodejs ]
buildInputs = [ tarWrapper python nodejs dos2unix ]
++ lib.optional (stdenv.isLinux) utillinux
++ lib.optional (stdenv.isDarwin) libtool
++ buildInputs;
Expand Down Expand Up @@ -535,6 +535,8 @@ let
do
file="$(readlink -f "$i")"
chmod u+rwx "$file"
isScript "$file" || continue
dos2unix "$file"
patchShebangs "$file"
done
fi
Expand Down
2 changes: 1 addition & 1 deletion tests/default-v14.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

let
nodeEnv = import ../nix/node-env.nix {
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
inherit (pkgs) stdenv lib python2 dos2unix runCommand writeTextFile writeShellScript;
inherit pkgs nodejs;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};
Expand Down
2 changes: 1 addition & 1 deletion tests/default-v16.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

let
nodeEnv = import ../nix/node-env.nix {
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
inherit (pkgs) stdenv lib python2 dos2unix runCommand writeTextFile writeShellScript;
inherit pkgs nodejs;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};
Expand Down
2 changes: 1 addition & 1 deletion tests/grunt/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let
inherit (pkgs) stdenv lib nix-gitignore fetchurl fetchgit;
});
nodeEnv = import ../../nix/node-env.nix {
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
inherit (pkgs) stdenv lib python2 dos2unix runCommand writeTextFile writeShellScript;
inherit pkgs nodejs;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};
Expand Down
2 changes: 1 addition & 1 deletion tests/lockfile-v2/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

let
nodeEnv = import ../../nix/node-env.nix {
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
inherit (pkgs) stdenv lib python2 dos2unix runCommand writeTextFile writeShellScript;
inherit pkgs nodejs;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};
Expand Down
2 changes: 1 addition & 1 deletion tests/lockfile/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

let
nodeEnv = import ../../nix/node-env.nix {
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
inherit (pkgs) stdenv lib python2 dos2unix runCommand writeTextFile writeShellScript;
inherit pkgs nodejs;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};
Expand Down
2 changes: 1 addition & 1 deletion tests/scoped/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

let
nodeEnv = import ../../nix/node-env.nix {
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
inherit (pkgs) stdenv lib python2 dos2unix runCommand writeTextFile writeShellScript;
inherit pkgs nodejs;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};
Expand Down
2 changes: 1 addition & 1 deletion tests/versionless/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

let
nodeEnv = import ../../nix/node-env.nix {
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
inherit (pkgs) stdenv lib python2 dos2unix runCommand writeTextFile writeShellScript;
inherit pkgs nodejs;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};
Expand Down

0 comments on commit 090516b

Please sign in to comment.