2017-05-31 18:44:46 +02:00
|
|
|
{ stdenv }@defs:
|
|
|
|
|
|
|
|
{
|
|
|
|
name
|
2017-06-09 18:04:33 +02:00
|
|
|
# gemdir is the location of the Gemfile{,.lock} and gemset.nix; usually ./.
|
2017-05-31 18:44:46 +02:00
|
|
|
, gemdir
|
2017-06-09 18:04:33 +02:00
|
|
|
# Exes is the list of executables provided by the gems in the Gemfile
|
2017-05-31 18:44:46 +02:00
|
|
|
, exes ? []
|
2017-06-11 01:58:32 +02:00
|
|
|
# Scripts are ruby programs depend on gems in the Gemfile (e.g. scripts/rails)
|
2017-05-31 18:44:46 +02:00
|
|
|
, scripts ? []
|
2017-06-09 18:04:33 +02:00
|
|
|
, gemfile ? null
|
|
|
|
, lockfile ? null
|
|
|
|
, gemset ? null
|
2017-06-11 01:58:32 +02:00
|
|
|
, preferLocalBuild ? false
|
|
|
|
, allowSubstitutes ? false
|
2017-05-31 18:44:46 +02:00
|
|
|
, postBuild
|
|
|
|
}@args:
|
|
|
|
|
|
|
|
let
|
2017-06-09 18:04:33 +02:00
|
|
|
basicEnv = (callPackage ../bundled-common {}) args;
|
2017-05-31 18:44:46 +02:00
|
|
|
|
|
|
|
args = removeAttrs args_ [ "name" "postBuild" ]
|
|
|
|
// { inherit preferLocalBuild allowSubstitutes; }; # pass the defaults
|
|
|
|
in
|
|
|
|
runCommand name args ''
|
2017-06-09 18:04:33 +02:00
|
|
|
mkdir -p ${out}/bin; cd $out;
|
2017-05-31 18:44:46 +02:00
|
|
|
${(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}
|
|
|
|
''
|