nixpkgs/pkgs/development/ruby-modules/tool/default.nix

37 lines
1.2 KiB
Nix
Raw Normal View History

{ stdenv }@defs:
{
name
# gemdir is the location of the Gemfile{,.lock} and gemset.nix; usually ./.
, gemdir
# Exes is the list of executables provided by the gems in the Gemfile
, exes ? []
2017-06-11 01:58:32 +02:00
# Scripts are ruby programs depend on gems in the Gemfile (e.g. scripts/rails)
, scripts ? []
, gemfile ? null
, lockfile ? null
, gemset ? null
2017-06-11 01:58:32 +02:00
, preferLocalBuild ? false
, allowSubstitutes ? false
, postBuild
}@args:
let
basicEnv = (callPackage ../bundled-common {}) args;
args = removeAttrs args_ [ "name" "postBuild" ]
// { inherit preferLocalBuild allowSubstitutes; }; # pass the defaults
in
runCommand name args ''
mkdir -p ${out}/bin; cd $out;
${(lib.concatMapStrings (x: "ln -s '${basicEnv}/bin/${x}' '${x}';\n") exes)}
${(lib.concatMapStrings (s: "makeWrapper ${out}/bin/$(basename ${s}) $srcdir/${s} " +
"--set BUNDLE_GEMFILE ${basicEnv.confFiles}/Gemfile "+
"--set BUNDLE_PATH ${basicEnv}/${ruby.gemPath} "+
"--set BUNDLE_FROZEN 1 "+
"--set GEM_HOME ${basicEnv}/${ruby.gemPath} "+
"--set GEM_PATH ${basicEnv}/${ruby.gemPath} "+
"--run \"cd $srcdir\";\n") scripts)}
${postBuild}
''