Made gemdir handling into a common function

This commit is contained in:
Judson 2017-06-09 09:04:33 -07:00
parent 0bde4071fc
commit 964d9b7a06
No known key found for this signature in database
GPG Key ID: 1817B08954BF0B7D
4 changed files with 21 additions and 33 deletions

View File

@ -7,10 +7,10 @@
{
name
, pname ? name
, gemdir
, gemfile
, lockfile
, gemset
, gemdir ? null
, gemfile ? null
, lockfile ? null
, gemset ? null
, ruby ? defs.ruby
, gemConfig ? defaultGemConfig
, postBuild ? null
@ -24,8 +24,9 @@
with import ./functions.nix { inherit lib gemConfig; };
let
gemFiles = bundlerFiles args;
importedGemset = import gemset;
importedGemset = import gemFiles.gemset;
filteredGemset = filterGemset { inherit ruby groups; } importedGemset;
@ -42,9 +43,9 @@ let
gems = lib.flip lib.mapAttrs configuredGemset (name: attrs: buildGem name attrs);
copyIfBundledByPath = { bundledByPath ? false, ...}@main:
(if bundledByPath then ''
cp -a ${gemdir}/* $out/
'' else ""
(if bundledByPath then
assert gemFiles.gemdir != nil; "cp -a ${gemFiles.gemdir}/* $out/"
else ""
);
maybeCopyAll = pname: if pname == null then "" else
@ -59,8 +60,8 @@ let
confFiles = runCommand "gemfile-and-lockfile" {} ''
mkdir -p $out
${maybeCopyAll pname}
cp ${gemfile} $out/Gemfile || ls -l $out/Gemfile
cp ${lockfile} $out/Gemfile.lock || ls -l $out/Gemfile.lock
cp ${gemFiles.gemfile} $out/Gemfile || ls -l $out/Gemfile
cp ${gemFiles.lockfile} $out/Gemfile.lock || ls -l $out/Gemfile.lock
'';
buildGem = name: attrs: (

View File

@ -27,23 +27,7 @@ let
else if pname != null then "${toString pname}-${basicEnv.gems."${pname}".version}"
else throw "bundlerEnv: either pname or name must be set";
gemfile' =
if gemfile == null then gemdir + "/Gemfile"
else gemfile;
lockfile' =
if lockfile == null then gemdir + "/Gemfile.lock"
else lockfile;
gemset' =
if gemset == null then gemdir + "/gemset.nix"
else gemset;
basicEnv = (callPackage ../bundled-common {}) (args // { inherit pname name gemdir;
gemfile = gemfile';
lockfile = lockfile';
gemset = gemset';
});
basicEnv = (callPackage ../bundled-common {}) (args // { inherit pname name; });
inherit (basicEnv) envPaths;
# Idea here is a mkDerivation that gen-bin-stubs new stubs "as specified" -

View File

@ -4,6 +4,7 @@ let
testLine = report: "${okStr report} ${toString (report.index + 1)} ${report.description}" + testDirective report + testYaml report;
# These are part of the TAP spec, not yet implemented.
testDirective = report: "";
testYaml = report: "";

View File

@ -2,24 +2,26 @@
{
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 ? []
# Scripts are programs included directly in nixpkgs that depend on gems
, scripts ? []
, gemfile ? null
, lockfile ? null
, gemset ? null
, postBuild
}@args:
let
basicEnv = (callPackage ../bundled-common {}) (args // { inherit name gemdir;
gemfile = gemfile';
lockfile = lockfile';
gemset = gemset';
});
basicEnv = (callPackage ../bundled-common {}) args;
args = removeAttrs args_ [ "name" "postBuild" ]
// { inherit preferLocalBuild allowSubstitutes; }; # pass the defaults
in
runCommand name args ''
mkdir -p $out; cd $out;
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 "+