diff options
author | Charles Strahan <charles.c.strahan@gmail.com> | 2015-03-02 18:28:02 -0500 |
---|---|---|
committer | Charles Strahan <charles.c.strahan@gmail.com> | 2015-03-02 18:28:02 -0500 |
commit | b4d4b88988133b27dfe9b7c30f7f8c15799b31dc (patch) | |
tree | 3659a4c9ce26a98d490ddfeedfe8c78f3b62dda1 /pkgs/development/interpreters | |
parent | 584ca3646263ce8e304b116ab9c1e51e132f4921 (diff) | |
parent | 0deb3fce70542f13510678cf62b07fbdf3bacbd4 (diff) | |
download | nixlib-b4d4b88988133b27dfe9b7c30f7f8c15799b31dc.tar nixlib-b4d4b88988133b27dfe9b7c30f7f8c15799b31dc.tar.gz nixlib-b4d4b88988133b27dfe9b7c30f7f8c15799b31dc.tar.bz2 nixlib-b4d4b88988133b27dfe9b7c30f7f8c15799b31dc.tar.lz nixlib-b4d4b88988133b27dfe9b7c30f7f8c15799b31dc.tar.xz nixlib-b4d4b88988133b27dfe9b7c30f7f8c15799b31dc.tar.zst nixlib-b4d4b88988133b27dfe9b7c30f7f8c15799b31dc.zip |
Merge pull request #6147 from abbradar/bundlerenv-env
bundler-env: add .env
Diffstat (limited to 'pkgs/development/interpreters')
-rw-r--r-- | pkgs/development/interpreters/ruby/bundler-env/default.nix | 121 |
1 files changed, 74 insertions, 47 deletions
diff --git a/pkgs/development/interpreters/ruby/bundler-env/default.nix b/pkgs/development/interpreters/ruby/bundler-env/default.nix index f90e756030f0..ea4e141b8fe5 100644 --- a/pkgs/development/interpreters/ruby/bundler-env/default.nix +++ b/pkgs/development/interpreters/ruby/bundler-env/default.nix @@ -246,67 +246,94 @@ let (map mkBuildFlags (lib.filter needsBuildFlags (attrValues instantiated))); -in + derivation = stdenv.mkDerivation { + inherit name; -stdenv.mkDerivation { - inherit name; + buildInputs = [ + ruby + bundler + git + ]; - buildInputs = [ - ruby - bundler - git - ]; + phases = [ "installPhase" "fixupPhase" ]; - phases = [ "installPhase" "fixupPhase" ]; + outputs = [ + "out" # the installed libs/bins + "bundle" # supporting files for bundler + ]; - outputs = [ - "out" # the installed libs/bins - "bundle" # supporting files for bundler - ]; + installPhase = '' + mkdir -p $bundle + export BUNDLE_GEMFILE=$bundle/Gemfile + cp ${gemfile} $BUNDLE_GEMFILE + cp ${purifiedLockfile} $BUNDLE_GEMFILE.lock - installPhase = '' - mkdir -p $bundle - export BUNDLE_GEMFILE=$bundle/Gemfile - cp ${gemfile} $BUNDLE_GEMFILE - cp ${purifiedLockfile} $BUNDLE_GEMFILE.lock + export NIX_GEM_SOURCES=${sources} + export NIX_BUNDLER_GEMPATH=${bundler}/${ruby.gemPath} - export NIX_GEM_SOURCES=${sources} - export NIX_BUNDLER_GEMPATH=${bundler}/${ruby.gemPath} + export GEM_HOME=$out/${ruby.gemPath} + export GEM_PATH=$NIX_BUNDLER_GEMPATH:$GEM_HOME + mkdir -p $GEM_HOME - export GEM_HOME=$out/${ruby.gemPath} - export GEM_PATH=$NIX_BUNDLER_GEMPATH:$GEM_HOME - mkdir -p $GEM_HOME + ${allBuildFlags} - ${allBuildFlags} + mkdir gems + cp ${bundler}/${bundler.ruby.gemPath}/cache/bundler-*.gem gems + ${copyGems} - mkdir gems - cp ${bundler}/${bundler.ruby.gemPath}/cache/bundler-*.gem gems - ${copyGems} + ${lib.optionalString (!documentation) '' + mkdir home + HOME="$(pwd -P)/home" + echo "gem: --no-rdoc --no-ri" > $HOME/.gemrc + ''} - ${lib.optionalString (!documentation) '' - mkdir home - HOME="$(pwd -P)/home" - echo "gem: --no-rdoc --no-ri" > $HOME/.gemrc - ''} + mkdir env + ${runPreInstallers} - mkdir env - ${runPreInstallers} + mkdir $out/bin + cp ${./monkey_patches.rb} monkey_patches.rb + export RUBYOPT="-rmonkey_patches.rb -I $(pwd -P)" + bundler install --frozen --binstubs ${lib.optionalString enableParallelBuilding "--jobs $NIX_BUILD_CORES"} + RUBYOPT="" - mkdir $out/bin - cp ${./monkey_patches.rb} monkey_patches.rb - export RUBYOPT="-rmonkey_patches.rb -I $(pwd -P)" - bundler install --frozen --binstubs ${lib.optionalString enableParallelBuilding "--jobs $NIX_BUILD_CORES"} - RUBYOPT="" + runHook postInstall + ''; - runHook postInstall - ''; + inherit postInstall; - inherit postInstall; + passthru = { + inherit ruby; + inherit bundler; + + env = let + irbrc = builtins.toFile "irbrc" '' + if not ENV["OLD_IRBRC"].empty? + require ENV["OLD_IRBRC"] + end + require 'rubygems' + require 'bundler/setup' + ''; + in stdenv.mkDerivation { + name = "interactive-${name}-environment"; + nativeBuildInputs = [ ruby derivation ]; + shellHook = '' + export BUNDLE_GEMFILE=${derivation.bundle}/Gemfile + export GEM_HOME=${derivation}/${ruby.gemPath} + export NIX_BUNDLER_GEMPATH=${bundler}/${ruby.gemPath} + export GEM_PATH=$NIX_BUNDLER_GEMPATH:$GEM_HOME + export OLD_IRBRC="$IRBRC" + export IRBRC=${irbrc} + ''; + buildCommand = '' + echo >&2 "" + echo >&2 "*** Ruby 'env' attributes are intended for interactive nix-shell sessions, not for building! ***" + echo >&2 "" + exit 1 + ''; + }; + }; - passthru = { - inherit ruby; - inherit bundler; + inherit meta; }; - inherit meta; -} +in derivation |