Using pname and fetching versions
This commit is contained in:
parent
70e7e543c5
commit
e149f02344
|
@ -5,8 +5,8 @@
|
|||
}@defs:
|
||||
|
||||
{
|
||||
name
|
||||
, pname ? name
|
||||
name ? null
|
||||
, pname ? null
|
||||
, mainGemName ? null
|
||||
, gemdir ? null
|
||||
, gemfile ? null
|
||||
|
@ -22,6 +22,8 @@
|
|||
, ...
|
||||
}@args:
|
||||
|
||||
assert name == null -> pname != null;
|
||||
|
||||
with import ./functions.nix { inherit lib gemConfig; };
|
||||
|
||||
let
|
||||
|
@ -43,6 +45,20 @@ let
|
|||
|
||||
gems = lib.flip lib.mapAttrs configuredGemset (name: attrs: buildGem name attrs);
|
||||
|
||||
name' = if name != null then
|
||||
name
|
||||
else
|
||||
let
|
||||
gem = gems."${pname}";
|
||||
version = gem.version;
|
||||
in
|
||||
"${pname}-${version}";
|
||||
|
||||
pname' = if pname != null then
|
||||
pname
|
||||
else
|
||||
name;
|
||||
|
||||
copyIfBundledByPath = { bundledByPath ? false, ...}@main:
|
||||
(if bundledByPath then
|
||||
assert gemFiles.gemdir != null; "cp -a ${gemFiles.gemdir}/* $out/"
|
||||
|
@ -78,9 +94,9 @@ let
|
|||
envPaths = lib.attrValues gems ++ lib.optional (!hasBundler) bundler;
|
||||
|
||||
basicEnv = buildEnv {
|
||||
inherit ignoreCollisions;
|
||||
inherit ignoreCollisions;
|
||||
|
||||
name = if name == null then pname else name;
|
||||
name = name';
|
||||
|
||||
paths = envPaths;
|
||||
pathsToLink = [ "/lib" ];
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
# (shell)> bundix
|
||||
# Then use rubyTool in the default.nix:
|
||||
|
||||
# rubyTool { name = "gemifiedTool"; gemdir = ./.; exes = ["gemified-tool"]; }
|
||||
# rubyTool { pname = "gemifiedTool"; gemdir = ./.; exes = ["gemified-tool"]; }
|
||||
# The 'exes' parameter ensures that a copy of e.g. rake doesn't polute the system.
|
||||
{
|
||||
name
|
||||
# use the name of the name in question; its version will be picked up from the gemset
|
||||
pname
|
||||
# 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
|
||||
|
@ -30,10 +31,10 @@
|
|||
let
|
||||
basicEnv = (callPackage ../bundled-common {}) args;
|
||||
|
||||
cmdArgs = removeAttrs args [ "name" "postBuild" ]
|
||||
cmdArgs = removeAttrs args [ "pname" "postBuild" ]
|
||||
// { inherit preferLocalBuild allowSubstitutes; }; # pass the defaults
|
||||
in
|
||||
runCommand name cmdArgs ''
|
||||
runCommand basicEnv.name cmdArgs ''
|
||||
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} " +
|
||||
|
|
|
@ -22,11 +22,6 @@
|
|||
let
|
||||
inherit (import ../bundled-common/functions.nix {inherit lib ruby gemConfig groups; }) genStubsScript;
|
||||
|
||||
drvName =
|
||||
if name != null then lib.traceVal name
|
||||
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; mainGemName = pname; });
|
||||
|
||||
inherit (basicEnv) envPaths;
|
||||
|
@ -48,7 +43,7 @@ in
|
|||
(buildEnv {
|
||||
inherit ignoreCollisions;
|
||||
|
||||
name = drvName;
|
||||
name = basicEnv.name;
|
||||
|
||||
paths = envPaths;
|
||||
pathsToLink = [ "/lib" ];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ lib, rubyTool }:
|
||||
{ lib, bundlerApp }:
|
||||
|
||||
bundlerApp {
|
||||
pname = "corundum";
|
||||
|
|
Loading…
Reference in a new issue