New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pythonPackages.binwalk: add dependencies #94268
Conversation
This seems like you should package I'm not sure if the current PR would solve the issue. IIRC, python packages which are passed through propagatedBuildInputs don't propagate their commands, just the packages. |
propagatedBuildInputs = [ zlib xz ncompress gzip bzip2 gnutar p7zip cabextract cramfsswap cramfsprogs lzma pycrypto ] | ||
++ stdenv.lib.optional visualizationSupport pyqtgraph; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not checked the other tools. I suspect they also should be in PATH rather than
propagatedBuildInputs
.
propagatedBuildInputs = [ zlib xz ncompress gzip bzip2 gnutar p7zip cabextract cramfsswap cramfsprogs lzma pycrypto ] | |
++ stdenv.lib.optional visualizationSupport pyqtgraph; | |
propagatedBuildInputs = [ zlib xz ncompress gzip bzip2 gnutar p7zip cabextract lzma pycrypto ] | |
++ stdenv.lib.optional visualizationSupport pyqtgraph; | |
makeWrapperArgs = ["--prefix" "PATH" ":" (stdenv.lib.makeBinPath [ cramfsswap cramfsprogs ])]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what this addition is supposed to do:
When I nix-shell --pure -p 'python3.withPackages(ps: with ps; [binwalk])'
, the $PATH
is not changed whether I this line (makeWrapperArgs
...) is present in the expression or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonringer, you made a similar proposition below: What is that supposed to do?
I am not too sure I am testing that correctly 😕: I don't see any difference when I am adding the aforementioned line:
# cramfsswap is still not available via the binwalk package
$ nix-shell --pure -p 'python3.withPackages(ps: with ps; [binwalk])' --run "cramfsswap"
/tmp/nix-shell-13495-0/rc: line 1: cramfsswap: command not found
# while it works when imported itself
$ nix-shell --pure -p cramfsswap --run "cramfsswap"
Usage: cramfsswap <in> <out>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Poke @Mic92 , @jonringer .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pamplemousse you don't want to change the PATH of your nix-shell but the PATH of the binwalk
executable. If you execute binwalk from the nix store directly without nix-shell, than cramfs
won't be in PATH. Note that nix-shell also packs propagated build inputs into your PATH, however those are not proper runtime dependencies but build dependencies instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this makes sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mic92 , thanks for the explanation. So, if I understand correctly:
Using the makeWrapperArgs ...
allows to solve the error (aforementioned in the first comment) both when invoking binwalk
from a nix-shell
, but also from the executable in the nix store.
As for the second part of your remark, I am not quite sure I get the full implications of what you say:
- So, adding
cramfsswap cramfsprogs
to thepropagatedBuildInputs
do not make them runtime dependencies... Is it only incidental that withoutmakeWrapperArgs
, and usingnix-shell
(because they are added to itsPATH
) the error was solved when I tested? - I kinda hoped those binaries to be available in the shell when importing
binwalk
, is that an over-expectation? (i.e. it is "normal" for import of python modules not to expose in thenix-shell
the binaries they rely on)
@jonringer Interesting... It did "solve my issue" (i.e., I can extract the content of a CramFs image using $ nix-shell -p 'python3.withPackages(ps: with ps; [binwalk])' --run "binwalk -e firmwares/FW_BU-2015_1.03.18_2014-06-05"
DECIMAL HEXADECIMAL DESCRIPTION
--------------------------------------------------------------------------------
128 0x80 CramFS filesystem, little endian, size: 9912320, version 2, sorted_dirs, CRC 0xCA750C65, edition 0, 5736 blocks, 607 files However, $ nix-shell -p 'python3.withPackages(ps: with ps; [binwalk])' --run "cramfsswap"
/tmp/nix-shell-20130-0/rc: line 1: cramfsswap: command not found
$ nix-shell -p 'python3.withPackages(ps: with ps; [binwalk])' --run "cramfsck"
/tmp/nix-shell-20177-0/rc: line 1: cramfsck: command not found I wonder how |
I added a commit to update the expression of # before
$ nix-shell --pure -p 'cramfsswap' --run 'cramfsswap -h'/nixpkgs
/tmp/nix-shell-10374-0/rc: line 1: cramfsswap: command not found
# after
$ nix-shell --pure -p 'cramfsswap' --run 'cramfsswap -h'
Usage: cramfsswap <in> <out> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could be wrong about the propagatedBuildInputs and PATH, but I still think it would be preferable to do something like:
makeWrapperArgs = [ "--prefix PATH : ${makeBinPath [ cramfsswap cramfsprogs ]} ';
As I have seen large dev closures when propagating native packages.
Fortunately, this doesnt seem to be the case here:
$ nix path-info -Sh ./result
/nix/store/6h3cq7dk6g3v0zq235sa8plgafifqv5k-python3.8-binwalk-2.2.0 160.0M
[nix-shell:/home/jon/.cache/nixpkgs-review/pr-94268]$ nix path-info -Sh ./results/python37Packages.binwalk
/nix/store/xxcdvxp77lzwxp8a4gwkap0qb3rdzrkz-python3.7-binwalk-2.2.0 157.7M
I think you pushed some commits by accident |
Signed-off-by: Pamplemousse <xav.maso@gmail.com>
Signed-off-by: Pamplemousse <xav.maso@gmail.com>
Signed-off-by: Pamplemousse <xav.maso@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
shows usage
https://github.com/NixOS/nixpkgs/pull/94268
8 packages built:
cramfsprogs cramfsswap python27Packages.binwalk python27Packages.binwalk-full python37Packages.binwalk python37Packages.binwalk-full python38Packages.binwalk python38Packages.binwalk-full
Motivation for this change
Allow
binwalk
to extractCramFS
content.Here is the error I get with the current version:
This comment explicitly states that
cramfsck
andcramfsswap
are required to work.Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)