2012-09-13 14:35:35 +02:00
|
|
|
{ pkgs, stdenv, nodejs, fetchurl, neededNatives }:
|
2012-07-25 23:46:21 +02:00
|
|
|
|
2013-05-28 04:29:00 +02:00
|
|
|
let
|
2013-05-29 17:22:18 +02:00
|
|
|
inherit (self) buildNodePackage patchLatest;
|
|
|
|
|
|
|
|
importGeneratedPackages = generated: nativeDeps: self: builtins.listToAttrs (pkgs.lib.fold (pkg: pairs:
|
2013-05-28 04:29:00 +02:00
|
|
|
(pkgs.lib.optional pkg.topLevel { name = pkg.baseName; value = builtins.getAttr pkg.fullName self; }) ++ [
|
|
|
|
{
|
|
|
|
name = pkg.fullName;
|
2013-05-29 17:22:18 +02:00
|
|
|
value = buildNodePackage rec {
|
2013-05-28 04:29:00 +02:00
|
|
|
name = "${pkg.baseName}-${pkg.version}";
|
2013-05-29 17:22:18 +02:00
|
|
|
src = (if pkg.patchLatest then patchLatest else fetchurl) {
|
2013-05-28 04:29:00 +02:00
|
|
|
url = "http://registry.npmjs.org/${pkg.baseName}/-/${name}.tgz";
|
|
|
|
sha256 = pkg.hash;
|
|
|
|
};
|
|
|
|
deps = map (dep: builtins.getAttr "${dep.name}-${dep.range}" self) pkg.dependencies;
|
|
|
|
buildInputs = if builtins.hasAttr name nativeDeps then builtins.getAttr name nativeDeps else [];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
] ++ pairs
|
2013-05-29 17:22:18 +02:00
|
|
|
) [] generated);
|
2013-05-28 04:29:00 +02:00
|
|
|
|
|
|
|
self = {
|
2013-05-29 17:22:18 +02:00
|
|
|
inherit importGeneratedPackages;
|
|
|
|
|
|
|
|
nativeDeps = {
|
|
|
|
"node-expat-*" = [ pkgs.expat ];
|
|
|
|
"rbytes-0.0.2" = [ pkgs.openssl ];
|
|
|
|
};
|
|
|
|
|
2013-05-28 04:29:00 +02:00
|
|
|
buildNodePackage = import ../development/web/nodejs/build-node-package.nix {
|
|
|
|
inherit stdenv nodejs neededNatives;
|
|
|
|
inherit (pkgs) runCommand;
|
|
|
|
};
|
|
|
|
|
|
|
|
patchLatest = srcAttrs:
|
|
|
|
let src = fetchurl srcAttrs; in pkgs.runCommand src.name {} ''
|
|
|
|
mkdir unpack
|
|
|
|
cd unpack
|
|
|
|
tar xf ${src}
|
|
|
|
mv */ package 2>/dev/null || true
|
|
|
|
sed -i -e "s/: \"latest\"/: \"*\"/" package/package.json
|
|
|
|
tar cf $out *
|
|
|
|
'';
|
|
|
|
|
|
|
|
/* Put manual packages below here (ideally eventually managed by npm2nix */
|
2013-05-29 17:22:18 +02:00
|
|
|
} // importGeneratedPackages (import ./node-packages-generated.nix) self.nativeDeps self;
|
2012-07-25 23:46:21 +02:00
|
|
|
in self
|