diff options
4 files changed, 19 insertions, 7 deletions
diff --git a/pkgs/development/ruby-modules/bundled-common/default.nix b/pkgs/development/ruby-modules/bundled-common/default.nix index 2aea35844fe5..354353ffab11 100644 --- a/pkgs/development/ruby-modules/bundled-common/default.nix +++ b/pkgs/development/ruby-modules/bundled-common/default.nix @@ -7,6 +7,7 @@ { name , pname ? name +, mainGemName ? null , gemdir ? null , gemfile ? null , lockfile ? null @@ -44,13 +45,13 @@ let copyIfBundledByPath = { bundledByPath ? false, ...}@main: (if bundledByPath then - assert gemFiles.gemdir != nil; "cp -a ${gemFiles.gemdir}/* $out/" + assert gemFiles.gemdir != null; "cp -a ${gemFiles.gemdir}/* $out/" else "" ); - maybeCopyAll = pname: if pname == null then "" else + maybeCopyAll = pkgname: if pkgname == null then "" else let - mainGem = gems."${pname}" or (throw "bundlerEnv: gem ${pname} not found"); + mainGem = gems."${pkgname}" or (throw "bundlerEnv: gem ${pkgname} not found"); in copyIfBundledByPath mainGem; @@ -59,7 +60,7 @@ let # out. Yes, I'm serious. confFiles = runCommand "gemfile-and-lockfile" {} '' mkdir -p $out - ${maybeCopyAll pname} + ${maybeCopyAll mainGemName} cp ${gemFiles.gemfile} $out/Gemfile || ls -l $out/Gemfile cp ${gemFiles.lockfile} $out/Gemfile.lock || ls -l $out/Gemfile.lock ''; diff --git a/pkgs/development/ruby-modules/bundled-common/functions.nix b/pkgs/development/ruby-modules/bundled-common/functions.nix index 1d7c4878e13b..b17a4639e779 100644 --- a/pkgs/development/ruby-modules/bundled-common/functions.nix +++ b/pkgs/development/ruby-modules/bundled-common/functions.nix @@ -7,6 +7,8 @@ rec { , gemdir ? null , ... }: { + inherit gemdir; + gemfile = if gemfile == null then assert gemdir != null; gemdir + "/Gemfile" else gemfile; diff --git a/pkgs/development/ruby-modules/bundler-env/default.nix b/pkgs/development/ruby-modules/bundler-env/default.nix index a72647fb00a1..7d175cfeccb7 100644 --- a/pkgs/development/ruby-modules/bundler-env/default.nix +++ b/pkgs/development/ruby-modules/bundler-env/default.nix @@ -27,7 +27,7 @@ let else if pname != null then "${toString pname}-${basicEnv.gems."${pname}".version}" else throw "bundlerEnv: either pname or name must be set"; - basicEnv = (callPackage ../bundled-common {}) (args // { inherit pname name; }); + basicEnv = (callPackage ../bundled-common {}) (args // { inherit pname name; mainGemName = pname; }); inherit (basicEnv) envPaths; # Idea here is a mkDerivation that gen-bin-stubs new stubs "as specified" - diff --git a/pkgs/development/ruby-modules/tool/default.nix b/pkgs/development/ruby-modules/tool/default.nix index 9b8848592b2c..a5308b79ff3d 100644 --- a/pkgs/development/ruby-modules/tool/default.nix +++ b/pkgs/development/ruby-modules/tool/default.nix @@ -1,5 +1,14 @@ { lib, stdenv, callPackage, runCommand, ruby }@defs: +# Use for simple installation of Ruby tools shipped in a Gem. +# Start with a Gemfile that includes `gem <toolgem>` +# > nix-shell -p bundler bundix +# (shell)> bundle lock +# (shell)> bundix +# Then use rubyTool in the default.nix: + +# rubyTool { name = "gemifiedTool"; gemdir = ./.; exes = ["gemified-tool"]; } +# The 'exes' parameter ensures that a copy of e.g. rake doesn't polute the system. { name # gemdir is the location of the Gemfile{,.lock} and gemset.nix; usually ./. @@ -25,8 +34,8 @@ let // { inherit preferLocalBuild allowSubstitutes; }; # pass the defaults in runCommand name cmdArgs '' - mkdir -p $out/bin; cd $out; - ${(lib.concatMapStrings (x: "ln -s '${basicEnv}/bin/${x}' '${x}';\n") exes)} + mkdir -p $out/bin; + ${(lib.concatMapStrings (x: "ln -s '${basicEnv}/bin/${x}' $out/bin/${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} "+ |