[Nix-dev] Packaging Bash Scripts

Shea Levy shea at shealevy.com
Thu Aug 30 00:53:23 CEST 2012


On 08/29/2012 09:20 AM, Alexander Foremny wrote:
> Hello Shea,
>
> thank you very much for your response! I modified my Nix expression
> [1]. Is this correct?

It looks like you forget to specify what to set $PATH to, I think you 
need to specify ${curl}/bin or some such

> Is there a way to test if things are actually working? Apparently I
> cannot remove curl from my profile.

If you check the resultant binary (it will be a shell script if created 
with wrapProgram), you should see $PATH getting set (or augmented) with 
the relevant path.

>> $ nix-env -e curl
>> $ curl --help
>> Usage: curl [options...]<url>
>> ...
> The commands above prints curl's help text which I did not expect.
>
> Regards,
> Alexander Foremny
>
> [1] https://github.com/aforemny/nixpkgs/blob/aed5c366944b98624411c5551f2d43becafdf44d/pkgs/tools/misc/plowshare/default.nix
>
> 2012/8/29 Shea Levy<shea at shealevy.com>:
>> Hi Alexander,
>>
>>
>> On 08/29/2012 05:27 AM, Alexander Foremny wrote:
>>> Hello list,
>>>
>>> I am currently trying to create a Nix expression for plowshare [1]. I
>>> got a working version [2] already, since installation is quite
>>> straight forward. However, as mentioned in the pull request I am
>>> worrying about purity.
>>>
>>> In particular the Bash script calls the curl binary. The first
>>> observation is that running one of plowshare's executables the curl
>>> binary is being found correctly. I think this is because curl is
>>> available in my PATH.
>>>
>>>> $ which curl
>>>> ~/.nix-profile/bin/curl
>>> I would have expected that this wouldn't be the case if I had removed
>>> curl from my environment. However, the following still yields the same
>>> result.
>>>
>>>> $ nix-env -e curl
>>>> $ which curl
>>>> ~/.nix-profile/bin/curl
>>> This also arises in a newly created shell and I can also execute the
>>> curl binary. I am guessing that curl is some kind of NixOS' standard
>>> environment. Is this correct?
>>>
>>> Is it considered an impurity that plowshare finds curl without
>>> depending on curl's derivation? If this is the case, is this impurity
>>> introduced by NixOS or by the Nix expression?
>>
>> It's an impurity in plowshare's nix expression.
>>
>>
>>> If this is an issue, how would I solve it? Should I patch plowshare's
>>> Bash scripts to refer to the curl's derivation instead of `which
>>> curl`? Or even better, is there a wrapper for this kind of programs
>>> already?
>>
>> wrapProgram (available if you add makeWrapper to buildInputs) is probably
>> what you want. An example of how it can be used is at
>> https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/taxes/aangifte-2011/default.nix#L30
>>
>>> Regards,
>>> Alexander Foremny
>>>
>>> [1] http://code.google.com/p/plowshare/
>>> [2] https://github.com/NixOS/nixpkgs/pull/117
>>> _______________________________________________
>>> nix-dev mailing list
>>> nix-dev at lists.science.uu.nl
>>> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>>



More information about the nix-dev mailing list