mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-18 19:51:17 +00:00
parent
03575caf9d
commit
25e582c497
93
pkgs/servers/meteor/default.nix
Normal file
93
pkgs/servers/meteor/default.nix
Normal file
|
@ -0,0 +1,93 @@
|
|||
{ stdenv, lib, fetchurl, zlib, patchelf }:
|
||||
|
||||
let
|
||||
bootstrap = fetchurl {
|
||||
url = "https://d3sqy0vbqsdhku.cloudfront.net/packages-bootstrap/1.2.0.1/meteor-bootstrap-os.linux.x86_64.tar.gz";
|
||||
sha256 = "0jc516qyig7f5a8ns4y6d9031f0ww2sd90n837kz6x97nin7655s";
|
||||
};
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "meteor-${version}";
|
||||
version = "1.2.0.1";
|
||||
|
||||
dontStrip = true;
|
||||
|
||||
unpackPhase = ''
|
||||
tar xf ${bootstrap}
|
||||
sourceRoot=.meteor
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
|
||||
cp -r packages $out
|
||||
chmod -R +w $out/packages
|
||||
|
||||
cp -r package-metadata $out
|
||||
chmod -R +w $out/package-metadata
|
||||
|
||||
devBundle=$(find $out/packages/meteor-tool -name dev_bundle)
|
||||
ln -s $devBundle $out/dev_bundle
|
||||
|
||||
toolsDir=$(dirname $(find $out/packages -print | grep "meteor-tool/.*/tools/index.js$"))
|
||||
ln -s $toolsDir $out/tools
|
||||
|
||||
# Patch Meteor to dynamically fixup shebangs and ELF metadata where
|
||||
# necessary.
|
||||
pushd $out
|
||||
patch -p1 < ${./main.patch}
|
||||
popd
|
||||
substituteInPlace $out/tools/cli/main.js \
|
||||
--replace "@INTERPRETER@" "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--replace "@RPATH@" "${stdenv.cc.cc}/lib:${zlib}/lib" \
|
||||
--replace "@PATCHELF@" "${patchelf}/bin/patchelf"
|
||||
|
||||
# Patch node.
|
||||
node=$devBundle/bin/node
|
||||
patchelf \
|
||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
--set-rpath "$(patchelf --print-rpath $node):${stdenv.cc.cc}/lib" \
|
||||
$node
|
||||
|
||||
# Patch mongo.
|
||||
for p in $devBundle/mongodb/bin/mongo{,d}; do
|
||||
patchelf \
|
||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
--set-rpath "$(patchelf --print-rpath $p):${stdenv.cc.cc}/lib:${zlib}/lib" \
|
||||
$p
|
||||
done
|
||||
|
||||
# Patch node dlls.
|
||||
for p in $(find $out/packages -name '*.node'); do
|
||||
patchelf \
|
||||
--set-rpath "$(patchelf --print-rpath $p):${stdenv.cc.cc}/lib" \
|
||||
$p
|
||||
done
|
||||
|
||||
# Meteor needs an initial package-metadata in $HOME/.meteor,
|
||||
# otherwise it fails spectacularly.
|
||||
mkdir -p $out/bin
|
||||
cat << EOF > $out/bin/meteor
|
||||
#!${stdenv.shell}
|
||||
|
||||
if [[ ! -f \$HOME/.meteor/package-metadata/v2.0.1/packages.data.db ]]; then
|
||||
mkdir -p \$HOME/.meteor/package-metadata/v2.0.1
|
||||
cp $out/package-metadata/v2.0.1/packages.data.db "\$HOME/.meteor/package-metadata/v2.0.1"
|
||||
chown "\$(whoami)" "\$HOME/.meteor/package-metadata/v2.0.1/packages.data.db"
|
||||
chmod +w "\$HOME/.meteor/package-metadata/v2.0.1/packages.data.db"
|
||||
fi
|
||||
|
||||
$node \''${TOOL_NODE_FLAGS} $out/tools/index.js "\$@"
|
||||
EOF
|
||||
chmod +x $out/bin/meteor
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Complete open source platform for building web and mobile apps in pure JavaScript";
|
||||
homepage = "http://www.meteor.com";
|
||||
license = licenses.mit;
|
||||
platforms = [ "x86_64-linux" ];
|
||||
maintainers = with maintainers; [ cstrahan ];
|
||||
};
|
||||
}
|
49
pkgs/servers/meteor/main.patch
Normal file
49
pkgs/servers/meteor/main.patch
Normal file
|
@ -0,0 +1,49 @@
|
|||
diff --git a/tools/cli/main.js b/tools/cli/main.js
|
||||
index 84f94bc..4fbda17 100644
|
||||
--- a/tools/cli/main.js
|
||||
+++ b/tools/cli/main.js
|
||||
@@ -484,6 +484,44 @@ var springboard = function (rel, options) {
|
||||
process.exit(ret.wait());
|
||||
}
|
||||
|
||||
+ // BEGIN HACK
|
||||
+ // patch shebang:
|
||||
+ var fs = require('fs');
|
||||
+ var path = require("path")
|
||||
+ var srcOld = fs.readFileSync(executable, 'utf8');
|
||||
+ srcNew = srcOld.replace(/^#!\/bin\/bash/, '#!/bin/sh');
|
||||
+ if (srcOld !== srcNew) {
|
||||
+ fs.writeFileSync(executable, srcNew, 'utf8');
|
||||
+ }
|
||||
+ // patch elfs:
|
||||
+ var dir = path.dirname(executable);
|
||||
+ var interpreter = "@INTERPRETER@";
|
||||
+ var rpath = "@RPATH@";
|
||||
+ function spawnSync(/*...*/) {
|
||||
+ var args = Array.prototype.slice.call(arguments);
|
||||
+ var proc = require("child_process").spawn.apply(null, args);
|
||||
+ var future = new Future();
|
||||
+ proc.on('close', function (code) {
|
||||
+ future.return();
|
||||
+ });
|
||||
+ return future.wait();
|
||||
+ }
|
||||
+ function patchelf(/*...*/) {
|
||||
+ var pathParts = Array.prototype.slice.call(arguments);
|
||||
+ var p = path.join.apply(null, [dir, "dev_bundle"].concat(pathParts));
|
||||
+ spawnSync('@PATCHELF@', [
|
||||
+ "--set-interpreter",
|
||||
+ interpreter,
|
||||
+ "--set-rpath",
|
||||
+ rpath,
|
||||
+ p
|
||||
+ ], {stdio: 'inherit'});
|
||||
+ }
|
||||
+ patchelf("bin", "node");
|
||||
+ patchelf("mongodb", "bin", "mongo");
|
||||
+ patchelf("mongodb", "bin", "mongod");
|
||||
+ // END HACK
|
||||
+
|
||||
// Now exec; we're not coming back.
|
||||
require('kexec')(executable, newArgv);
|
||||
throw Error('exec failed?');
|
|
@ -9016,6 +9016,8 @@ let
|
|||
|
||||
memcached = callPackage ../servers/memcached {};
|
||||
|
||||
meteor = callPackage ../servers/meteor/default.nix { };
|
||||
|
||||
# Backwards compatibility.
|
||||
mod_dnssd = pkgs.apacheHttpdPackages.mod_dnssd;
|
||||
mod_evasive = pkgs.apacheHttpdPackages.mod_evasive;
|
||||
|
|
Loading…
Reference in a new issue