Created
January 6, 2015 21:35
-
-
Save benley/9b1e52a4f31a2d62ec12 to your computer and use it in GitHub Desktop.
nix expression for a custom ruby app with various custom gem dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs, stdenv, ruby, rubygems, rubyLibs, ... }: | |
let | |
myGems = pkgs.recurseIntoAttrs (pkgs.callPackage ./rubylibs.nix { }); | |
synapse_requirements = [ | |
rubyLibs.aws_sdk | |
myGems.zk | |
myGems.docker_api | |
]; | |
in | |
stdenv.mkDerivation rec { | |
name = "synapse-aurora-${version}"; | |
version = "0.11.2.1"; | |
src = pkgs.fetchgit { | |
url = "https://github.com/benley/synapse.git"; | |
rev = "70008ef0431d907991195a207135e86cbcb0387c"; | |
sha256 = "a44e11d361a5d2d3fe71710a78571471609a23a82d8ac80f327f77fac6d46369"; | |
}; | |
meta = { | |
description = "Synapse with Aurora support"; | |
homepage = "https://github.com/benley/synapse"; | |
}; | |
buildInputs = with pkgs; [ ruby rubygems git makeWrapper ]; | |
propagatedBuildInputs = synapse_requirements; | |
buildPhase = "gem build synapse.gemspec"; | |
installPhase = '' | |
set -x | |
export HOME=$TMP/home; mkdir -pv "$HOME" | |
gem install \ | |
--ignore-dependencies \ | |
--install-dir "$out/${ruby.gemPath}" \ | |
--bindir "$out/bin" \ | |
"${name}.gem" $gemFlags -- $buildFlags | |
# Don't keep the .gem file in the finished package | |
rm -frv "$out/${ruby.gemPath}/cache" | |
addToSearchPath GEM_PATH "$out/${ruby.gemPath}" | |
for prog in $out/bin/*; do | |
wrapProgram "$prog" \ | |
--prefix GEM_PATH : "$GEM_PATH" \ | |
--prefix RUBYLIB : "${rubygems}/lib" \ | |
--set RUBYOPT rubygems \ | |
$extraWrapperFlags ''${extraWrapperFlagsArray[@]} | |
done | |
# Make sure all the executables are actually in the package | |
for prog in $out/gems/*/bin/*; do | |
[[ -e "$out/bin/$(basename $prog)" ]] | |
done | |
# looks like useless files which break build repeatability and consume space | |
rm $out/${ruby.gemPath}/doc/*/*/created.rid \ | |
$out/${ruby.gemPath}/gems/*/ext/*/mkmf.log || true | |
runHook postInstall | |
''; | |
propagatedUserEnvPkgs = synapse_requirements; | |
passthru.isRubyGem = true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# WARNING: automatically generated file | |
# Generated by 'gem nix' command that comes from 'nix' gem | |
g: # Get dependencies from patched gems | |
{ | |
aliases = { | |
archive_tar_minitar = g.archive_tar_minitar_0_5_2; | |
aws_sdk = g.aws_sdk_1_60_2; | |
aws_sdk_v1 = g.aws_sdk_v1_1_60_2; | |
docker_api = g.docker_api_1_17_0; | |
excon = g.excon_0_42_1; | |
json = g.json_1_8_1; | |
little_plugger = g.little_plugger_1_1_3; | |
logging = g.logging_1_8_2; | |
mini_portile = g.mini_portile_0_6_2; | |
multi_json = g.multi_json_1_10_1; | |
nokogiri = g.nokogiri_1_6_5; | |
synapse_aurora = g.synapse_aurora_0_11_2_1; | |
zk = g.zk_1_9_4; | |
zookeeper = g.zookeeper_1_4_9; | |
}; | |
gem_nix_args = [ ''synapse-aurora'' ]; | |
gems = { | |
archive_tar_minitar_0_5_2 = { | |
basename = ''archive_tar_minitar''; | |
meta = { | |
description = ''Provides POSIX tarchive management from Ruby programs.''; | |
homepage = ''http://rubyforge.org/projects/ruwiki/''; | |
longDescription = ''Archive::Tar::Minitar is a pure-Ruby library and command-line utility that provides the ability to deal with POSIX tar(1) archive files. The implementation is based heavily on Mauricio Ferna'ndez's implementation in rpa-base, but has been reorganised to promote reuse in other projects.''; | |
}; | |
name = ''archive-tar-minitar-0.5.2''; | |
requiredGems = [ ]; | |
sha256 = ''1j666713r3cc3wb0042x0wcmq2v11vwwy5pcaayy5f0lnd26iqig''; | |
}; | |
aws_sdk_1_60_2 = { | |
basename = ''aws_sdk''; | |
meta = { | |
description = ''AWS SDK for Ruby V1''; | |
homepage = ''http://aws.amazon.com/sdkforruby''; | |
longDescription = ''Version 1 of the AWS SDK for Ruby. Available as both `aws-sdk` and `aws-sdk-v1`. | |
Use `aws-sdk-v1` if you want to load v1 and v2 of the Ruby SDK in the same | |
application.''; | |
}; | |
name = ''aws-sdk-1.60.2''; | |
requiredGems = [ g.aws_sdk_v1_1_60_2 ]; | |
sha256 = ''027d3c5sxh7d7528hsvmqlix0lja1f7kdpr9sn7130pqdd4mcmah''; | |
}; | |
aws_sdk_v1_1_60_2 = { | |
basename = ''aws_sdk_v1''; | |
meta = { | |
description = ''AWS SDK for Ruby V1''; | |
homepage = ''http://aws.amazon.com/sdkforruby''; | |
longDescription = ''Version 1 of the AWS SDK for Ruby. Available as both `aws-sdk` and `aws-sdk-v1`. | |
Use `aws-sdk-v1` if you want to load v1 and v2 of the Ruby SDK in the same | |
application.''; | |
}; | |
name = ''aws-sdk-v1-1.60.2''; | |
requiredGems = [ g.nokogiri_1_6_5 g.json_1_8_1 ]; | |
sha256 = ''0124zc4p4bcxa07npbf2ychbqlavfm923vsmm1cjz51k8zl49n9c''; | |
}; | |
docker_api_1_17_0 = { | |
basename = ''docker_api''; | |
meta = { | |
description = ''A simple REST client for the Docker Remote API''; | |
homepage = ''https://github.com/swipely/docker-api''; | |
longDescription = ''A simple REST client for the Docker Remote API''; | |
}; | |
name = ''docker-api-1.17.0''; | |
requiredGems = [ g.excon_0_42_1 g.json_1_8_1 g.archive_tar_minitar_0_5_2 ]; | |
sha256 = ''0ifc0hgssr6x2650wxn8i2mpmc8girb6vihbr1xlr6jb7j7l8r4v''; | |
}; | |
excon_0_42_1 = { | |
basename = ''excon''; | |
meta = { | |
description = ''speed, persistence, http(s)''; | |
homepage = ''https://github.com/excon/excon''; | |
longDescription = ''EXtended http(s) CONnections''; | |
}; | |
name = ''excon-0.42.1''; | |
requiredGems = [ ]; | |
sha256 = ''1za1jmp83149qmykih2bfgxlwyyz3hrpaq4kxww7467fvgwh58xj''; | |
}; | |
json_1_8_1 = { | |
basename = ''json''; | |
meta = { | |
description = ''JSON Implementation for Ruby''; | |
homepage = ''http://flori.github.com/json''; | |
longDescription = ''This is a JSON implementation as a Ruby extension in C.''; | |
}; | |
name = ''json-1.8.1''; | |
requiredGems = [ ]; | |
sha256 = ''0002bsycvizvkmk1jyv8px1hskk6wrjfk4f7x5byi8gxm6zzn6wn''; | |
}; | |
little_plugger_1_1_3 = { | |
basename = ''little_plugger''; | |
meta = { | |
description = ''LittlePlugger is a module that provides Gem based plugin management.''; | |
homepage = ''http://gemcutter.org/gems/little-plugger''; | |
longDescription = ''LittlePlugger is a module that provides Gem based plugin management. | |
By extending your own class or module with LittlePlugger you can easily | |
manage the loading and initializing of plugins provided by other gems.''; | |
}; | |
name = ''little-plugger-1.1.3''; | |
requiredGems = [ ]; | |
sha256 = ''0crxv0yl5iwmqzj2y7hh9s7qbwr7s7305vgdbsanbzq059ca98yp''; | |
}; | |
logging_1_8_2 = { | |
basename = ''logging''; | |
meta = { | |
description = ''A flexible and extendable logging library for Ruby''; | |
homepage = ''http://rubygems.org/gems/logging''; | |
longDescription = ''Logging is a flexible logging library for use in Ruby programs based on the | |
design of Java's log4j library. It features a hierarchical logging system, | |
custom level names, multiple output destinations per log event, custom | |
formatting, and more.''; | |
}; | |
name = ''logging-1.8.2''; | |
requiredGems = [ g.little_plugger_1_1_3 g.multi_json_1_10_1 ]; | |
sha256 = ''0vcckpk3sffhz9phpzkbbqzzcffsg2n292rmq5b4gx6dp9g4n86p''; | |
}; | |
mini_portile_0_6_2 = { | |
basename = ''mini_portile''; | |
meta = { | |
description = ''Simplistic port-like solution for developers''; | |
homepage = ''http://github.com/flavorjones/mini_portile''; | |
longDescription = ''Simplistic port-like solution for developers. It provides a standard and simplified way to compile against dependency libraries without messing up your system.''; | |
}; | |
name = ''mini_portile-0.6.2''; | |
requiredGems = [ ]; | |
sha256 = ''0h3xinmacscrnkczq44s6pnhrp4nqma7k056x5wv5xixvf2wsq2w''; | |
}; | |
multi_json_1_10_1 = { | |
basename = ''multi_json''; | |
meta = { | |
description = ''A common interface to multiple JSON libraries.''; | |
homepage = ''http://github.com/intridea/multi_json''; | |
longDescription = ''A common interface to multiple JSON libraries, including Oj, Yajl, the JSON gem (with C-extensions), the pure-Ruby JSON gem, NSJSONSerialization, gson.rb, JrJackson, and OkJson.''; | |
}; | |
name = ''multi_json-1.10.1''; | |
requiredGems = [ ]; | |
sha256 = ''1ll21dz01jjiplr846n1c8yzb45kj5hcixgb72rz0zg8fyc9g61c''; | |
}; | |
nokogiri_1_6_5 = { | |
basename = ''nokogiri''; | |
meta = { | |
description = ''Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser''; | |
homepage = ''http://nokogiri.org''; | |
longDescription = ''Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser. Among Nokogiri's | |
many features is the ability to search documents via XPath or CSS3 selectors. | |
XML is like violence - if it doesn’t solve your problems, you are not using | |
enough of it.''; | |
}; | |
name = ''nokogiri-1.6.5''; | |
requiredGems = [ g.mini_portile_0_6_2 ]; | |
sha256 = ''1xmxz6fa0m4p7c7ngpgz6gjgv65lzz63dsf0b6vh7gs2fkiw8j7l''; | |
}; | |
synapse_aurora_0_11_2_1 = { | |
basename = ''synapse_aurora''; | |
meta = { | |
description = ''Fork of Airbnb Synapse with support for Apache Aurora''; | |
homepage = ''https://github.com/benley/synapse''; | |
longDescription = ''Synapse is Airbnb's new system for service discovery. Synapse solves the | |
problem of automated fail-over in the cloud, where failover via network | |
re-configuration is impossible. The end result is the ability to connect | |
internal services together in a scalable, fault-tolerant way. | |
This is a forked version which adds support for Apache Aurora service | |
announcements. | |
''; | |
}; | |
name = ''synapse-aurora-0.11.2.1''; | |
requiredGems = [ g.aws_sdk_1_60_2 g.docker_api_1_17_0 g.zk_1_9_4 ]; | |
sha256 = ''0yhqxcczc6wycaqj8q36nmwv5f6vfhyjisiiasfd2zc5qqvi9jgr''; | |
}; | |
zk_1_9_4 = { | |
basename = ''zk''; | |
meta = { | |
description = ''A high-level wrapper around the zookeeper driver''; | |
homepage = ''https://github.com/slyphon/zk''; | |
longDescription = ''A high-level wrapper around the zookeeper driver | |
''; | |
}; | |
name = ''zk-1.9.4''; | |
requiredGems = [ g.zookeeper_1_4_9 g.logging_1_8_2 ]; | |
sha256 = ''1rgghyhnbqp7lcn0vik3rn93msv51igsh5cwag88rp6hhnvd141j''; | |
}; | |
zookeeper_1_4_9 = { | |
basename = ''zookeeper''; | |
meta = { | |
description = ''Apache ZooKeeper driver for Rubies''; | |
homepage = ''https://github.com/slyphon/zookeeper''; | |
longDescription = ''A low-level multi-Ruby wrapper around the ZooKeeper API bindings. For a | |
friendlier interface, see http://github.com/slyphon/zk. Currently supported: | |
MRI: {1.8.7, 1.9.2, 1.9.3}, JRuby: ~> 1.6.7, Rubinius: 2.0.testing, REE 1.8.7. | |
This library uses version 3.4.5 of zookeeper bindings. | |
''; | |
}; | |
name = ''zookeeper-1.4.9''; | |
requiredGems = [ ]; | |
sha256 = ''1zjb8sri15nqyqv1w9v34dv2d7q1lf3phr126mcfrj8v6vawhzcc''; | |
}; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ stdenv, config, fetchurl, callPackage | |
, gemfile ? ./Gemfile.nix | |
, patches ? null | |
, overrides ? null | |
}: | |
let | |
inherit (stdenv.lib) fold optional; | |
gemsMergeableFun = { generatedFuns ? [], patchFuns ? [], overrideFuns ? [] }: | |
let | |
generatedAttrs = map (f: f customGems) generatedFuns; | |
generatedGems = map (a: a.gems) generatedAttrs; | |
gem = callPackage <nixpkgs/pkgs/development/interpreters/ruby/gem.nix> { | |
patches = map (f: callPackage f { inherit gems; }) patchFuns; | |
overrides = map (f: callPackage f { }) overrideFuns; | |
}; | |
customGems = stdenv.lib.mapAttrs gem (fold (x: y: x // y) { } generatedGems); | |
gems = fold (x: y: x // y) customGems (map (a: a.aliases) generatedAttrs); | |
in | |
gems // { | |
merge = { generated ? null, patches ? null, overrides ? null }: | |
gemsMergeableFun { | |
generatedFuns = generatedFuns ++ optional (generated != null) generated; | |
patchFuns = patchFuns ++ optional (patches != null) patches; | |
overrideFuns = overrideFuns ++ optional (overrides != null) overrides; | |
}; | |
}; | |
in | |
((gemsMergeableFun { }).merge { | |
generated = import gemfile; | |
inherit patches; | |
inherit overrides; | |
}).merge ( | |
let | |
getLocalGemFun = name: stdenv.lib.attrByPath [ "gems" name ] null config; | |
in | |
{ | |
generated = getLocalGemFun "generated"; | |
patches = getLocalGemFun "patches"; | |
overrides = getLocalGemFun "overrides"; | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment