2013-05-31 17:50:28 +01:00
|
|
|
{ pkgs, stdenv, nodejs, fetchurl, neededNatives, self }:
|
2012-07-25 22:46:21 +01:00
|
|
|
|
2013-05-28 03:29:00 +01:00
|
|
|
let
|
2013-05-29 16:22:18 +01:00
|
|
|
inherit (self) buildNodePackage patchLatest;
|
|
|
|
|
2013-05-31 17:38:26 +01:00
|
|
|
importGeneratedPackages = generated: nativeDeps: self:
|
|
|
|
let
|
|
|
|
all = pkgs.lib.fold (pkg: { top-level, full }: {
|
|
|
|
top-level = top-level ++ pkgs.lib.optional pkg.topLevel {
|
|
|
|
name = pkg.baseName;
|
|
|
|
value = builtins.getAttr pkg.fullName self.full;
|
2013-05-28 03:29:00 +01:00
|
|
|
};
|
2013-05-31 17:38:26 +01:00
|
|
|
full = [ {
|
|
|
|
name = pkg.fullName;
|
2013-05-31 18:27:55 +01:00
|
|
|
value = pkgs.lib.makeOverridable buildNodePackage rec {
|
2013-05-31 17:38:26 +01:00
|
|
|
name = "${pkg.baseName}-${pkg.version}";
|
|
|
|
src = (if pkg.patchLatest then patchLatest else fetchurl) {
|
|
|
|
url = "http://registry.npmjs.org/${pkg.baseName}/-/${name}.tgz";
|
|
|
|
sha256 = pkg.hash;
|
|
|
|
};
|
|
|
|
deps = map (dep: builtins.getAttr "${dep.name}-${dep.range}" self.full) pkg.dependencies;
|
|
|
|
buildInputs = if builtins.hasAttr name nativeDeps then builtins.getAttr name nativeDeps else [];
|
|
|
|
};
|
|
|
|
} ] ++ full;
|
|
|
|
} ) { top-level = []; full = []; } generated;
|
|
|
|
in builtins.listToAttrs all.top-level // { full = builtins.listToAttrs all.full; };
|
2013-05-31 17:50:28 +01:00
|
|
|
in {
|
|
|
|
inherit importGeneratedPackages;
|
2013-05-28 03:29:00 +01:00
|
|
|
|
2013-05-31 17:50:28 +01:00
|
|
|
nativeDeps = {
|
|
|
|
"node-expat-*" = [ pkgs.expat ];
|
|
|
|
"rbytes-0.0.2" = [ pkgs.openssl ];
|
|
|
|
};
|
2013-05-29 16:22:18 +01:00
|
|
|
|
2013-05-31 17:50:28 +01:00
|
|
|
buildNodePackage = import ../development/web/nodejs/build-node-package.nix {
|
|
|
|
inherit stdenv nodejs neededNatives;
|
|
|
|
inherit (pkgs) runCommand;
|
|
|
|
};
|
2013-05-29 16:22:18 +01:00
|
|
|
|
2013-05-31 17:50:28 +01:00
|
|
|
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 *
|
|
|
|
'';
|
2013-05-28 03:29:00 +01:00
|
|
|
|
2013-05-31 17:50:28 +01:00
|
|
|
/* Put manual packages below here (ideally eventually managed by npm2nix */
|
|
|
|
} // importGeneratedPackages (import ./node-packages-generated.nix) self.nativeDeps self
|