[Nix-dev] Package a Simple Python Script

Sergiu Ivanov sivanov at colimite.fr
Thu Sep 1 14:53:28 CEST 2016


Hi Roland,

Thank you for your answer!

Sorry for the big delay: I didn't want to reply back before I had some
definite conclusion.

Thus quoth  Roland Koebler  at 02:39 on So, Aug 28 2016:
>
>> I am trying to package adb-sync [0], which is essentially a Python
>> script.  I can easily write a default.nix taking this script from the
>> source directory and putting it into $out/bin (cf. attached file).  I
>> have some trouble with this approach though: the _runtime_ dependencies
>> (Python and Android SDK) are not installed.
> Have you tried to use "propagatedBuildInputs" instead of "buildInputs"?
>
> See: https://nixos.org/nixpkgs/manual/#sec-python
>
>     As in Perl, dependencies on other Python packages can be specified
>     in the buildInputs and propagatedBuildInputs attributes. If
>     something is exclusively a build-time dependency, use buildInputs;
>     if it’s (also) a runtime dependency, use propagatedBuildInputs.

Oh, I see, I had only read the explanation of propagatedBuildInputs in
the description of mkDerivation, and I thought this attribute was only
relevant for building something else against my package.  Yet, just as
you point out, apparently it may be used to specify runtime dependencies
for Perl and Python packages.


I played around with propagatedBuildInputs until I realised that, even
though Nix would pull in Python for my package, Python would not appear
on my PATH because I don't install it explicitly.  Moreover, Nix would
also pull in Python if I specified it in buildInputs already.  Therefore
I managed to solve my problem essentially by patching the shebang line.

My current solution is this pull request [0].

-- 
Sergiu

[0] https://github.com/NixOS/nixpkgs/pull/18189/files
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160901/8804a5cf/attachment.sig>


More information about the nix-dev mailing list