[Nix-dev] A generic wrapper method (possibly)

Eelco Dolstra eelco.dolstra at logicblox.com
Mon Dec 2 15:23:30 CET 2013


Hi,

On 30/11/13 16:12, Bjørn Forsman wrote:

> I envision the end result to be something like this:
> 
> stdenv.mkDerivation {
>   name = "foo-0.1";
>   ...
>   buildInputs = [ python pythonPackages.jedi ];
>   runtimeInputs = [ python pythonPackages.jedi ];
>   ...
> }
> 
> (The use of python above is arbitrary. You could for instance replace
> it with bash + some deps that should be found in PATH.)
> 
> The above derivation, when built, would construct a wrapped instance
> of the python interpreter which knows where to find the jedi package.
> And this interpreter would be used in the patchShebangs function.
> Automatically.
> 
> What do you think? Does this sound like a good idea?

Using a wrapped interpreter certainly sounds nicer than using a wrapper.  I see
two problems:

- wrapProgram is used for more than adding runtime inputs; it can also set
arbitrary environment variables (e.g. $MOZ_PLUGIN_PATH in the Firefox wrapper).

- You may want to have different runtime inputs for different programs in a
derivation.

An alternative that I've been thinking about is to make wrapProgram smarter by
giving it interpreter-specific backends.  For instance, if the program to be
wrapped is a shell script, we don't need to generate a wrapper: we can just add
some lines to be top of the shell script.  Likewise for other interpreted
languages.  It may even be possible for ELF executables (patchelf could override
the main() function to do some setenv() calls).

-- 
Eelco Dolstra | LogicBlox, Inc. | http://nixos.org/~eelco/


More information about the nix-dev mailing list