nodePackages: correctly handle platforms and optional dependencies

This commit is contained in:
Jaka Hudoklin 2015-02-28 04:03:24 +01:00
parent ea13e2aa87
commit bd81885f70

View File

@ -57,15 +57,20 @@ let
mv $(find . -type d -mindepth 1 -maxdepth 1) $out mv $(find . -type d -mindepth 1 -maxdepth 1) $out
''; '';
platforms = fold (entry: platforms: platforms = if os == [] then nodejs.meta.platforms else
let fold (entry: platforms:
filterPlatforms = attrByPath [(removePrefix "!" entry)] [] stdenv.lib.platforms; let
in filterPlatforms =
if hasPrefix "!" entry then stdenv.lib.platforms.${removePrefix "!" entry} or [];
filter (p: any (f: p != f) filterPlatforms) platforms in
else # Ignore unknown platforms
filter (p: any (f: p == f) filterPlatforms) platforms if filterPlatforms == [] then platforms
) nodejs.meta.platforms os; else
if hasPrefix "!" entry then
substract (intersect filterPlatforms nodejs.meta.platforms) platforms
else
platforms ++ (intersect filterPlatforms nodejs.meta.platforms)
) [] os;
mapDependencies = deps: f: rec { mapDependencies = deps: f: rec {
# Convert deps to attribute set # Convert deps to attribute set
@ -87,8 +92,8 @@ let
_dependencies = mapDependencies deps (name: dep: _dependencies = mapDependencies deps (name: dep:
dep.pkgName != pkgName); dep.pkgName != pkgName);
_optionalDependencies = mapDependencies optionalDependencies (name: dep: _optionalDependencies = mapDependencies optionalDependencies (name: dep:
any (platform: stdenv.system == platform) dep.meta.platforms && (builtins.tryEval dep).success &&
all (d: d != dep.pkgName) skipOptionalDependencies !(elem dep.pkgName skipOptionalDependencies)
); );
_peerDependencies = mapDependencies peerDependencies (name: dep: _peerDependencies = mapDependencies peerDependencies (name: dep:
dep.pkgName != pkgName); dep.pkgName != pkgName);
@ -301,7 +306,7 @@ let
dontStrip = true; dontStrip = true;
meta = { meta = {
platforms = platforms; inherit platforms;
maintainers = [ stdenv.lib.maintainers.offline ]; maintainers = [ stdenv.lib.maintainers.offline ];
}; };