Merge pull request #6147 from abbradar/bundlerenv-env

bundler-env: add .env
This commit is contained in:
Charles Strahan 2015-03-02 18:28:02 -05:00
commit b4d4b88988

View File

@ -246,67 +246,94 @@ let
(map mkBuildFlags (map mkBuildFlags
(lib.filter needsBuildFlags (attrValues instantiated))); (lib.filter needsBuildFlags (attrValues instantiated)));
in derivation = stdenv.mkDerivation {
inherit name;
stdenv.mkDerivation { buildInputs = [
inherit name; ruby
bundler
git
];
buildInputs = [ phases = [ "installPhase" "fixupPhase" ];
ruby
bundler
git
];
phases = [ "installPhase" "fixupPhase" ]; outputs = [
"out" # the installed libs/bins
"bundle" # supporting files for bundler
];
outputs = [ installPhase = ''
"out" # the installed libs/bins mkdir -p $bundle
"bundle" # supporting files for bundler export BUNDLE_GEMFILE=$bundle/Gemfile
]; cp ${gemfile} $BUNDLE_GEMFILE
cp ${purifiedLockfile} $BUNDLE_GEMFILE.lock
installPhase = '' export NIX_GEM_SOURCES=${sources}
mkdir -p $bundle export NIX_BUNDLER_GEMPATH=${bundler}/${ruby.gemPath}
export BUNDLE_GEMFILE=$bundle/Gemfile
cp ${gemfile} $BUNDLE_GEMFILE
cp ${purifiedLockfile} $BUNDLE_GEMFILE.lock
export NIX_GEM_SOURCES=${sources} export GEM_HOME=$out/${ruby.gemPath}
export NIX_BUNDLER_GEMPATH=${bundler}/${ruby.gemPath} export GEM_PATH=$NIX_BUNDLER_GEMPATH:$GEM_HOME
mkdir -p $GEM_HOME
export GEM_HOME=$out/${ruby.gemPath} ${allBuildFlags}
export GEM_PATH=$NIX_BUNDLER_GEMPATH:$GEM_HOME
mkdir -p $GEM_HOME
${allBuildFlags} mkdir gems
cp ${bundler}/${bundler.ruby.gemPath}/cache/bundler-*.gem gems
${copyGems}
mkdir gems ${lib.optionalString (!documentation) ''
cp ${bundler}/${bundler.ruby.gemPath}/cache/bundler-*.gem gems mkdir home
${copyGems} HOME="$(pwd -P)/home"
echo "gem: --no-rdoc --no-ri" > $HOME/.gemrc
''}
${lib.optionalString (!documentation) '' mkdir env
mkdir home ${runPreInstallers}
HOME="$(pwd -P)/home"
echo "gem: --no-rdoc --no-ri" > $HOME/.gemrc
''}
mkdir env mkdir $out/bin
${runPreInstallers} 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 runHook postInstall
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 inherit postInstall;
'';
inherit postInstall; passthru = {
inherit ruby;
inherit bundler;
passthru = { env = let
inherit ruby; irbrc = builtins.toFile "irbrc" ''
inherit bundler; 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
'';
};
};
inherit meta;
}; };
inherit meta; in derivation
}