Unverified Commit e149f023 authored by Judson's avatar Judson
Browse files

Using pname and fetching versions

parent 70e7e543
Loading
Loading
Loading
Loading
+20 −4
Original line number Diff line number Diff line
@@ -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/"
@@ -80,7 +96,7 @@ let
  basicEnv = buildEnv {
    inherit  ignoreCollisions;

    name = if name == null then pname else name;
    name = name';

    paths = envPaths;
    pathsToLink = [ "/lib" ];
+5 −4
Original line number Diff line number Diff line
@@ -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} " +
+1 −6
Original line number Diff line number Diff line
@@ -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 −1
Original line number Diff line number Diff line
{ lib, rubyTool }:
{ lib, bundlerApp }:

bundlerApp {
  pname = "corundum";