mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-27 01:13:05 +00:00
Using pname and fetching versions
This commit is contained in:
parent
70e7e543c5
commit
e149f02344
@ -5,8 +5,8 @@
|
|||||||
}@defs:
|
}@defs:
|
||||||
|
|
||||||
{
|
{
|
||||||
name
|
name ? null
|
||||||
, pname ? name
|
, pname ? null
|
||||||
, mainGemName ? null
|
, mainGemName ? null
|
||||||
, gemdir ? null
|
, gemdir ? null
|
||||||
, gemfile ? null
|
, gemfile ? null
|
||||||
@ -22,6 +22,8 @@
|
|||||||
, ...
|
, ...
|
||||||
}@args:
|
}@args:
|
||||||
|
|
||||||
|
assert name == null -> pname != null;
|
||||||
|
|
||||||
with import ./functions.nix { inherit lib gemConfig; };
|
with import ./functions.nix { inherit lib gemConfig; };
|
||||||
|
|
||||||
let
|
let
|
||||||
@ -43,6 +45,20 @@ let
|
|||||||
|
|
||||||
gems = lib.flip lib.mapAttrs configuredGemset (name: attrs: buildGem name attrs);
|
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:
|
copyIfBundledByPath = { bundledByPath ? false, ...}@main:
|
||||||
(if bundledByPath then
|
(if bundledByPath then
|
||||||
assert gemFiles.gemdir != null; "cp -a ${gemFiles.gemdir}/* $out/"
|
assert gemFiles.gemdir != null; "cp -a ${gemFiles.gemdir}/* $out/"
|
||||||
@ -78,9 +94,9 @@ let
|
|||||||
envPaths = lib.attrValues gems ++ lib.optional (!hasBundler) bundler;
|
envPaths = lib.attrValues gems ++ lib.optional (!hasBundler) bundler;
|
||||||
|
|
||||||
basicEnv = buildEnv {
|
basicEnv = buildEnv {
|
||||||
inherit ignoreCollisions;
|
inherit ignoreCollisions;
|
||||||
|
|
||||||
name = if name == null then pname else name;
|
name = name';
|
||||||
|
|
||||||
paths = envPaths;
|
paths = envPaths;
|
||||||
pathsToLink = [ "/lib" ];
|
pathsToLink = [ "/lib" ];
|
||||||
|
@ -7,10 +7,11 @@
|
|||||||
# (shell)> bundix
|
# (shell)> bundix
|
||||||
# Then use rubyTool in the default.nix:
|
# 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.
|
# 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 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 is the list of executables provided by the gems in the Gemfile
|
||||||
@ -30,10 +31,10 @@
|
|||||||
let
|
let
|
||||||
basicEnv = (callPackage ../bundled-common {}) args;
|
basicEnv = (callPackage ../bundled-common {}) args;
|
||||||
|
|
||||||
cmdArgs = removeAttrs args [ "name" "postBuild" ]
|
cmdArgs = removeAttrs args [ "pname" "postBuild" ]
|
||||||
// { inherit preferLocalBuild allowSubstitutes; }; # pass the defaults
|
// { inherit preferLocalBuild allowSubstitutes; }; # pass the defaults
|
||||||
in
|
in
|
||||||
runCommand name cmdArgs ''
|
runCommand basicEnv.name cmdArgs ''
|
||||||
mkdir -p $out/bin;
|
mkdir -p $out/bin;
|
||||||
${(lib.concatMapStrings (x: "ln -s '${basicEnv}/bin/${x}' $out/bin/${x};\n") exes)}
|
${(lib.concatMapStrings (x: "ln -s '${basicEnv}/bin/${x}' $out/bin/${x};\n") exes)}
|
||||||
${(lib.concatMapStrings (s: "makeWrapper $out/bin/$(basename ${s}) $srcdir/${s} " +
|
${(lib.concatMapStrings (s: "makeWrapper $out/bin/$(basename ${s}) $srcdir/${s} " +
|
||||||
|
@ -22,11 +22,6 @@
|
|||||||
let
|
let
|
||||||
inherit (import ../bundled-common/functions.nix {inherit lib ruby gemConfig groups; }) genStubsScript;
|
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; });
|
basicEnv = (callPackage ../bundled-common {}) (args // { inherit pname name; mainGemName = pname; });
|
||||||
|
|
||||||
inherit (basicEnv) envPaths;
|
inherit (basicEnv) envPaths;
|
||||||
@ -48,7 +43,7 @@ in
|
|||||||
(buildEnv {
|
(buildEnv {
|
||||||
inherit ignoreCollisions;
|
inherit ignoreCollisions;
|
||||||
|
|
||||||
name = drvName;
|
name = basicEnv.name;
|
||||||
|
|
||||||
paths = envPaths;
|
paths = envPaths;
|
||||||
pathsToLink = [ "/lib" ];
|
pathsToLink = [ "/lib" ];
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ lib, rubyTool }:
|
{ lib, bundlerApp }:
|
||||||
|
|
||||||
bundlerApp {
|
bundlerApp {
|
||||||
pname = "corundum";
|
pname = "corundum";
|
||||||
|
Loading…
Reference in New Issue
Block a user