git.iko.soy/typeable/nixpkgs
on master help sign in
nodePackages.node2nix: Remove `node_` prefix in buildNodePackage

Fixes #127137 This greatly improves compatibility with repology.org. As a side effect, more packages will be supported by automatic update tools

commit7f55664079f99883f910b672fe5ede77e0284277 authorpiegames <git@piegames.de> dateFri 9 Jul 2021, 00:42 (5 years ago) parent5dd4f2d
2 files changed+34−3
pkgs/development/node-packages/default.nix+26−1 pkgs/development/node-packages/node-env.nix+8−2
pkgs/development/node-packages/default.nix+26−1
@@ -1,4 +1,4 @@
1−{ pkgs, nodejs, stdenv, fetchFromGitHub }:
1+{ pkgs, nodejs, stdenv, applyPatches, fetchFromGitHub, fetchpatch }:
22
33let
44 since = (version: pkgs.lib.versionAtLeast nodejs.version version);
@@ -160,6 +160,31 @@ let
160160
161161 node2nix = super.node2nix.override {
162162 buildInputs = [ pkgs.makeWrapper ];
163+ # We need to apply a patch to the source, but buildNodePackage doesn't allow patches.
164+ # So we pin the patched commit instead. The commit actually contains two other newer commits
165+ # since the last (1.9.0) release, but actually this is a good thing since one of them is a
166+ # Hydra-specific fix.
167+ src = applyPatches {
168+ src = fetchFromGitHub {
169+ owner = "svanderburg";
170+ repo = "node2nix";
171+ rev = "node2nix-1.9.0";
172+ sha256 = "0l4wp1131nhl9c14cn8bwawb8f77h1nfbnswgi5lp5m3kzkb27jn";
173+ };
174+
175+ patches = [
176+ # remove node_ name prefix
177+ (fetchpatch {
178+ url = "https://github.com/svanderburg/node2nix/commit/b54d45207427ff46e90f16f2f32771fdc8bff5a4.patch";
179+ sha256 = "03cg2xwryvdlvg299dg91qxicrw2r43grja80an9zkb875ps8jxh";
180+ })
181+ # set meta platform
182+ (fetchpatch {
183+ url = "https://github.com/svanderburg/node2nix/commit/58736093161f2d237c17e75a96529b018cd0ac64.patch";
184+ sha256 = "1c91qfqa6p4hzyafv5pq6rpgnny2805n007b1443gbqwrz5awz6n";
185+ })
186+ ];
187+ };
163188 postInstall = ''
164189 wrapProgram "$out/bin/node2nix" --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.nix ]}
165190 '';
pkgs/development/node-packages/node-env.nix+8−2
@@ -391,13 +391,14 @@ let
391391 , dontStrip ? true
392392 , unpackPhase ? "true"
393393 , buildPhase ? "true"
394+ , meta ? {}
394395 , ... }@args:
395396
396397 let
397− extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" ];
398+ extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" "meta" ];
398399 in
399400 stdenv.mkDerivation ({
400− name = "node_${name}-${version}";
401+ name = "${name}-${version}";
401402 buildInputs = [ tarWrapper python nodejs ]
402403 ++ lib.optional (stdenv.isLinux) utillinux
403404 ++ lib.optional (stdenv.isDarwin) libtool
@@ -446,6 +447,11 @@ let
446447 # Run post install hook, if provided
447448 runHook postInstall
448449 '';
450+
451+ meta = {
452+ # default to Node.js' platforms
453+ platforms = nodejs.meta.platforms;
454+ } // meta;
449455 } // extraArgs);
450456
451457 # Builds a node environment (a node_modules folder and a set of binaries)