1 { stdenv, lib, fetchurl, zlib, curl, xz, patchelf, runtimeShell }:
6 inherit (stdenv.hostPlatform) system;
9 x86_64-linux = fetchurl {
10 url = "https://static-meteor.netdna-ssl.com/packages-bootstrap/${version}/meteor-bootstrap-os.linux.x86_64.tar.gz";
11 sha256 = "sha256-ovsE7jUJIKf96WEoITXECUlPo+o1tEKvHzCc7Xgj614=";
13 x86_64-darwin = fetchurl {
14 url = "https://static-meteor.netdna-ssl.com/packages-bootstrap/${version}/meteor-bootstrap-os.osx.x86_64.tar.gz";
15 sha256 = "11206dbda50a680fdab7044def7ea68ea8f4a9bca948ca56df91fe1392b2ac16";
23 src = srcs.${system} or (throw "unsupported system ${system}");
27 sourceRoot = ".meteor";
33 chmod -R +w $out/packages
35 cp -r package-metadata $out
37 devBundle=$(find $out/packages/meteor-tool -name dev_bundle)
38 ln -s $devBundle $out/dev_bundle
40 toolsDir=$(dirname $(find $out/packages -print | grep "meteor-tool/.*/tools/index.js$"))
41 ln -s $toolsDir $out/tools
43 # Meteor needs an initial package-metadata in $HOME/.meteor,
44 # otherwise it fails spectacularly.
46 cat << EOF > $out/bin/meteor
49 if [[ ! -f \$HOME/.meteor/package-metadata/v2.0.1/packages.data.db ]]; then
50 mkdir -p \$HOME/.meteor/package-metadata/v2.0.1
51 cp $out/package-metadata/v2.0.1/packages.data.db "\$HOME/.meteor/package-metadata/v2.0.1"
52 chown "\$(whoami)" "\$HOME/.meteor/package-metadata/v2.0.1/packages.data.db"
53 chmod +w "\$HOME/.meteor/package-metadata/v2.0.1/packages.data.db"
56 $out/dev_bundle/bin/node --no-wasm-code-gc \''${TOOL_NODE_FLAGS} $out/tools/index.js "\$@"
58 chmod +x $out/bin/meteor
61 postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
62 # Patch Meteor to dynamically fixup shebangs and ELF metadata where
65 patch -p1 < ${./main.patch}
67 substituteInPlace $out/tools/cli/main.js \
68 --replace "@INTERPRETER@" "$(cat $NIX_CC/nix-support/dynamic-linker)" \
69 --replace "@RPATH@" "${lib.makeLibraryPath [ stdenv.cc.cc zlib curl xz ]}" \
70 --replace "@PATCHELF@" "${patchelf}/bin/patchelf"
74 --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
75 --set-rpath "$(patchelf --print-rpath $out/dev_bundle/bin/node):${lib.getLib stdenv.cc.cc}/lib" \
76 $out/dev_bundle/bin/node
79 for p in $out/dev_bundle/mongodb/bin/mongo{,d}; do
81 --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
82 --set-rpath "$(patchelf --print-rpath $p):${lib.makeLibraryPath [ stdenv.cc.cc zlib curl xz ]}" \
87 for p in $(find $out/packages -name '*.node'); do
89 --set-rpath "$(patchelf --print-rpath $p):${lib.getLib stdenv.cc.cc}/lib" \
95 description = "Complete open source platform for building web and mobile apps in pure JavaScript";
96 homepage = "https://www.meteor.com/";
97 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
98 license = licenses.mit;
99 platforms = builtins.attrNames srcs;
101 mainProgram = "meteor";