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

View File

@ -27,23 +27,7 @@ let
else if pname != null then "${toString pname}-${basicEnv.gems."${pname}".version}" else if pname != null then "${toString pname}-${basicEnv.gems."${pname}".version}"
else throw "bundlerEnv: either pname or name must be set"; else throw "bundlerEnv: either pname or name must be set";
gemfile' = basicEnv = (callPackage ../bundled-common {}) (args // { inherit pname name; });
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';
});
inherit (basicEnv) envPaths; inherit (basicEnv) envPaths;
# Idea here is a mkDerivation that gen-bin-stubs new stubs "as specified" - # 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; 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: ""; testDirective = report: "";
testYaml = report: ""; testYaml = report: "";

View File

@ -2,24 +2,26 @@
{ {
name name
# gemdir is the location of the Gemfile{,.lock} and gemset.nix; usually ./.
, gemdir , gemdir
# Exes is the list of executables provided by the gems in the Gemfile
, exes ? [] , exes ? []
# Scripts are programs included directly in nixpkgs that depend on gems
, scripts ? [] , scripts ? []
, gemfile ? null
, lockfile ? null
, gemset ? null
, postBuild , postBuild
}@args: }@args:
let let
basicEnv = (callPackage ../bundled-common {}) (args // { inherit name gemdir; basicEnv = (callPackage ../bundled-common {}) args;
gemfile = gemfile';
lockfile = lockfile';
gemset = gemset';
});
args = removeAttrs args_ [ "name" "postBuild" ] args = removeAttrs args_ [ "name" "postBuild" ]
// { inherit preferLocalBuild allowSubstitutes; }; # pass the defaults // { inherit preferLocalBuild allowSubstitutes; }; # pass the defaults
in in
runCommand name args '' 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 (x: "ln -s '${basicEnv}/bin/${x}' '${x}';\n") exes)}
${(lib.concatMapStrings (s: "makeWrapper ${out}/bin/$(basename ${s}) $srcdir/${s} " + ${(lib.concatMapStrings (s: "makeWrapper ${out}/bin/$(basename ${s}) $srcdir/${s} " +
"--set BUNDLE_GEMFILE ${basicEnv.confFiles}/Gemfile "+ "--set BUNDLE_GEMFILE ${basicEnv.confFiles}/Gemfile "+