Fixing an overload of "pname"
This commit is contained in:
parent
fc302bc07f
commit
603e84caef
4 changed files with 19 additions and 7 deletions
|
@ -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
|
||||
'';
|
||||
|
|
|
@ -7,6 +7,8 @@ rec {
|
|||
, gemdir ? null
|
||||
, ...
|
||||
}: {
|
||||
inherit gemdir;
|
||||
|
||||
gemfile =
|
||||
if gemfile == null then assert gemdir != null; gemdir + "/Gemfile"
|
||||
else gemfile;
|
||||
|
|
|
@ -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" -
|
||||
|
|
|
@ -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} "+
|
||||
|
|
Loading…
Reference in a new issue