From e149f0234451e6ac714492076e5796546a2b035b Mon Sep 17 00:00:00 2001 From: Judson Date: Tue, 27 Jun 2017 22:33:18 -0700 Subject: [PATCH] Using pname and fetching versions --- .../ruby-modules/bundled-common/default.nix | 24 +++++++++++++++---- .../ruby-modules/bundler-app/default.nix | 9 +++---- .../ruby-modules/bundler-env/default.nix | 7 +----- pkgs/development/tools/corundum/default.nix | 2 +- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/pkgs/development/ruby-modules/bundled-common/default.nix b/pkgs/development/ruby-modules/bundled-common/default.nix index 6e7bd7a898bd..09eb36a247a4 100644 --- a/pkgs/development/ruby-modules/bundled-common/default.nix +++ b/pkgs/development/ruby-modules/bundled-common/default.nix @@ -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" ]; diff --git a/pkgs/development/ruby-modules/bundler-app/default.nix b/pkgs/development/ruby-modules/bundler-app/default.nix index a5308b79ff3d..99d1dd64dc4f 100644 --- a/pkgs/development/ruby-modules/bundler-app/default.nix +++ b/pkgs/development/ruby-modules/bundler-app/default.nix @@ -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} " + diff --git a/pkgs/development/ruby-modules/bundler-env/default.nix b/pkgs/development/ruby-modules/bundler-env/default.nix index 7d175cfeccb7..2e2653621a76 100644 --- a/pkgs/development/ruby-modules/bundler-env/default.nix +++ b/pkgs/development/ruby-modules/bundler-env/default.nix @@ -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" ]; diff --git a/pkgs/development/tools/corundum/default.nix b/pkgs/development/tools/corundum/default.nix index b7c0006a7b51..e149a25859ad 100644 --- a/pkgs/development/tools/corundum/default.nix +++ b/pkgs/development/tools/corundum/default.nix @@ -1,4 +1,4 @@ -{ lib, rubyTool }: +{ lib, bundlerApp }: bundlerApp { pname = "corundum";