From 964d9b7a067fc48d9774c5bff37d7fff41158f5a Mon Sep 17 00:00:00 2001 From: Judson Date: Fri, 9 Jun 2017 09:04:33 -0700 Subject: [PATCH] Made gemdir handling into a common function --- .../ruby-modules/bundled-common/default.nix | 21 ++++++++++--------- .../ruby-modules/bundler-env/default.nix | 18 +--------------- .../ruby-modules/testing/tap-support.nix | 1 + .../development/ruby-modules/tool/default.nix | 14 +++++++------ 4 files changed, 21 insertions(+), 33 deletions(-) diff --git a/pkgs/development/ruby-modules/bundled-common/default.nix b/pkgs/development/ruby-modules/bundled-common/default.nix index 30c82100d5e0..2aea35844fe5 100644 --- a/pkgs/development/ruby-modules/bundled-common/default.nix +++ b/pkgs/development/ruby-modules/bundled-common/default.nix @@ -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: ( diff --git a/pkgs/development/ruby-modules/bundler-env/default.nix b/pkgs/development/ruby-modules/bundler-env/default.nix index 89fafb5f230b..a72647fb00a1 100644 --- a/pkgs/development/ruby-modules/bundler-env/default.nix +++ b/pkgs/development/ruby-modules/bundler-env/default.nix @@ -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" - diff --git a/pkgs/development/ruby-modules/testing/tap-support.nix b/pkgs/development/ruby-modules/testing/tap-support.nix index 3147ed066c11..555ce89d8332 100644 --- a/pkgs/development/ruby-modules/testing/tap-support.nix +++ b/pkgs/development/ruby-modules/testing/tap-support.nix @@ -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: ""; diff --git a/pkgs/development/ruby-modules/tool/default.nix b/pkgs/development/ruby-modules/tool/default.nix index 02bf3b96a267..04c385d75ae6 100644 --- a/pkgs/development/ruby-modules/tool/default.nix +++ b/pkgs/development/ruby-modules/tool/default.nix @@ -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 "+