summary refs log tree commit diff
path: root/pkgs/development/ruby-modules/bundler-app
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2018-10-29 21:39:51 +0000
committerzimbatm <zimbatm@zimbatm.com>2018-10-29 22:39:51 +0100
commit69dcb1a2c0c5596fbbbe7fa50d4f8277c6f1ea6a (patch)
tree403e2a501a86ec4acee69b5ab74269d6ba9c2f70 /pkgs/development/ruby-modules/bundler-app
parent3947b88389d8d9cc938035b21eb1ee9d1f23b6a6 (diff)
downloadnixpkgs-69dcb1a2c0c5596fbbbe7fa50d4f8277c6f1ea6a.tar
nixpkgs-69dcb1a2c0c5596fbbbe7fa50d4f8277c6f1ea6a.tar.gz
nixpkgs-69dcb1a2c0c5596fbbbe7fa50d4f8277c6f1ea6a.tar.bz2
nixpkgs-69dcb1a2c0c5596fbbbe7fa50d4f8277c6f1ea6a.tar.lz
nixpkgs-69dcb1a2c0c5596fbbbe7fa50d4f8277c6f1ea6a.tar.xz
nixpkgs-69dcb1a2c0c5596fbbbe7fa50d4f8277c6f1ea6a.tar.zst
nixpkgs-69dcb1a2c0c5596fbbbe7fa50d4f8277c6f1ea6a.zip
bundlerApp: take buildInputs (#45435)
It would be reasonable to have a Ruby program that depends on some other
program being in the PATH. In this case, the obvious thing to do would
be something like this:

    bundlerApp {
      # ...
      buildInputs = [ makeWrapper ];
      postBuild = ''
        wrapProgram "$out/bin/foo" \
          --prefix PATH : ${lib.makeBinPath [ dep ]}
      '';
    }

However, this doesn't work, because even though it just forwards most of
its arguments to `runCommand`, `bundlerApp` won't take a `buildInputs`
parameter. It doesn't even specify its own `buildInputs`, which means
that the `scripts` parameter to `bundlerApp` (which depends on
`makeWrapper`) is completely broken, and, as far as I can tell, has been
since its inception. I've added a `makeWrapper` build input if the
scripts parameter is present to fix this.

I've added a `buildInputs` option to `bundlerApp`. It's also passed
through to bundled-common because `postBuild` scripts are run there as
well. This actually means that in this example we'd end up going through
two layers of wrappers (one from `bundlerApp` and one from
bundled-common), but that has always been the case and isn't likely to
break anything. That oddity does suggest that it might be prudent to
not forward `postBuild` to bundled-common (or to at least use a
different option) though...

FWIW, as far as I can tell no package in nixpkgs uses either the
`scripts` or `postBuild` options to `bundlerApp`.
Diffstat (limited to 'pkgs/development/ruby-modules/bundler-app')
-rw-r--r--pkgs/development/ruby-modules/bundler-app/default.nix24
1 files changed, 14 insertions, 10 deletions
diff --git a/pkgs/development/ruby-modules/bundler-app/default.nix b/pkgs/development/ruby-modules/bundler-app/default.nix
index 656896a8f7a..60e3a38517c 100644
--- a/pkgs/development/ruby-modules/bundler-app/default.nix
+++ b/pkgs/development/ruby-modules/bundler-app/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, callPackage, runCommand, ruby }@defs:
+{ lib, stdenv, callPackage, runCommand, makeWrapper, ruby }@defs:
 
 # Use for simple installation of Ruby tools shipped in a Gem.
 # Start with a Gemfile that includes `gem <toolgem>`
@@ -26,6 +26,7 @@
 , allowSubstitutes ? false
 , installManpages ? true
 , meta ? {}
+, buildInputs ? []
 , postBuild ? ""
 , gemConfig ? null
 }@args:
@@ -33,19 +34,22 @@
 let
   basicEnv = (callPackage ../bundled-common {}) args;
 
-  cmdArgs = removeAttrs args [ "pname" "postBuild" "gemConfig" ]
-  // { inherit preferLocalBuild allowSubstitutes; }; # pass the defaults
+  cmdArgs = removeAttrs args [ "pname" "postBuild" "gemConfig" ] // {
+    inherit preferLocalBuild allowSubstitutes; # pass the defaults
+
+    buildInputs = buildInputs ++ lib.optional (scripts != []) makeWrapper;
+  };
 in
-   runCommand basicEnv.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} " +
-            "--set BUNDLE_GEMFILE ${basicEnv.confFiles}/Gemfile "+
-            "--set BUNDLE_PATH ${basicEnv}/${ruby.gemPath} "+
-            "--set BUNDLE_FROZEN 1 "+
-            "--set GEM_HOME ${basicEnv}/${ruby.gemPath} "+
-            "--set GEM_PATH ${basicEnv}/${ruby.gemPath} "+
-            "--run \"cd $srcdir\";\n") scripts)}
+                                "--set BUNDLE_GEMFILE ${basicEnv.confFiles}/Gemfile "+
+                                "--set BUNDLE_PATH ${basicEnv}/${ruby.gemPath} "+
+                                "--set BUNDLE_FROZEN 1 "+
+                                "--set GEM_HOME ${basicEnv}/${ruby.gemPath} "+
+                                "--set GEM_PATH ${basicEnv}/${ruby.gemPath} "+
+                                "--run \"cd $srcdir\";\n") scripts)}
 
     ${lib.optionalString installManpages ''
     for section in {1..9}; do