mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 07:23:20 +00:00
nodePackages: correctly handle platforms and optional dependencies
This commit is contained in:
parent
ea13e2aa87
commit
bd81885f70
@ -57,15 +57,20 @@ let
|
||||
mv $(find . -type d -mindepth 1 -maxdepth 1) $out
|
||||
'';
|
||||
|
||||
platforms = fold (entry: platforms:
|
||||
platforms = if os == [] then nodejs.meta.platforms else
|
||||
fold (entry: platforms:
|
||||
let
|
||||
filterPlatforms = attrByPath [(removePrefix "!" entry)] [] stdenv.lib.platforms;
|
||||
filterPlatforms =
|
||||
stdenv.lib.platforms.${removePrefix "!" entry} or [];
|
||||
in
|
||||
if hasPrefix "!" entry then
|
||||
filter (p: any (f: p != f) filterPlatforms) platforms
|
||||
# Ignore unknown platforms
|
||||
if filterPlatforms == [] then platforms
|
||||
else
|
||||
filter (p: any (f: p == f) filterPlatforms) platforms
|
||||
) nodejs.meta.platforms os;
|
||||
if hasPrefix "!" entry then
|
||||
substract (intersect filterPlatforms nodejs.meta.platforms) platforms
|
||||
else
|
||||
platforms ++ (intersect filterPlatforms nodejs.meta.platforms)
|
||||
) [] os;
|
||||
|
||||
mapDependencies = deps: f: rec {
|
||||
# Convert deps to attribute set
|
||||
@ -87,8 +92,8 @@ let
|
||||
_dependencies = mapDependencies deps (name: dep:
|
||||
dep.pkgName != pkgName);
|
||||
_optionalDependencies = mapDependencies optionalDependencies (name: dep:
|
||||
any (platform: stdenv.system == platform) dep.meta.platforms &&
|
||||
all (d: d != dep.pkgName) skipOptionalDependencies
|
||||
(builtins.tryEval dep).success &&
|
||||
!(elem dep.pkgName skipOptionalDependencies)
|
||||
);
|
||||
_peerDependencies = mapDependencies peerDependencies (name: dep:
|
||||
dep.pkgName != pkgName);
|
||||
@ -301,7 +306,7 @@ let
|
||||
dontStrip = true;
|
||||
|
||||
meta = {
|
||||
platforms = platforms;
|
||||
inherit platforms;
|
||||
maintainers = [ stdenv.lib.maintainers.offline ];
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user