-
Notifications
You must be signed in to change notification settings - Fork 69
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
Add nix derivation #45
base: master
Are you sure you want to change the base?
Conversation
Convenience for NixOS / Nixpkgs users, `nix-build` ran in main project directory should build this and create a `result/` symlink pointing at a built package.
Thanks, but keep in mind that I don't have a CI/Environment to test NixOS. |
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.
Thanks for your contribution. Apart from my other comments: What's the reason for using a default.nix
instead of making it a Flake?
Note that I'm not involved with this project, just stumbled on the project when trying to reverse-engineer some firmware and saw your pull request.
src = ./.; | ||
|
||
buildInputs = [ | ||
pkgs.cmake |
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.
This needs to be in nativeBuildInputs
because otherwise you'll get cmake
for the target platform when cross-compiling.
|
||
buildInputs = [ | ||
pkgs.cmake | ||
pkgs.openssl.dev |
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.
No need to specify .dev
since this output is already used by default for buildInputs
.
|
||
configurePhase = '' | ||
cmake . | ||
''; | ||
|
||
buildPhase = '' | ||
make | ||
''; |
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.
configurePhase = '' | |
cmake . | |
''; | |
buildPhase = '' | |
make | |
''; |
If you place cmake
in nativeBuildInputs
, you get the right setup hooks and won't need this.
cd src | ||
cp epk2extract tools/lzhsenc tools/lzhs_scanner tools/idb_extract tools/jffs2extract $out/bin | ||
|
||
chmod -x ../keys/* |
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.
It's the upstream project, so no need to fix up something like this.
cp epk2extract tools/lzhsenc tools/lzhs_scanner tools/idb_extract tools/jffs2extract $out/bin | ||
|
||
chmod -x ../keys/* | ||
cp ../keys/*.key ../keys/*.pem $out/bin |
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.
This is pretty ugly IMO and those files ideally should be in $out/share/epk2extract
or something like that but certainly not in $out/bin
. Probably it's a good idea to make this configurable (see src/main.c:223) via cmake.
mkdir -p $out/bin | ||
cd src | ||
cp epk2extract tools/lzhsenc tools/lzhs_scanner tools/idb_extract tools/jffs2extract $out/bin |
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 know it's probably personal taste, but what about the following (which does not change the current working directory):
mkdir -p $out/bin | |
cd src | |
cp epk2extract tools/lzhsenc tools/lzhs_scanner tools/idb_extract tools/jffs2extract $out/bin | |
for i in src/epk2extract src/tools/{lzhsenc,lzhs_scanner,idb_extract,jffs2extract}; do | |
install -vD "$i" "$out/bin/$(basename "$i")" | |
done |
pname = "epk2extract"; | ||
version = "devel"; |
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.
Since we don't have an explicit version here, it's probably better to just use name
instead of pname
and version
:
pname = "epk2extract"; | |
version = "devel"; | |
name = "epk2extract"; |
@@ -31,3 +31,5 @@ src/tools/idb_extract | |||
src/tools/jffs2extract | |||
src/tools/lzhs_scanner | |||
src/tools/lzhsenc | |||
|
|||
result |
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.
Just a small nitpick:
result | |
/result |
Just a very simple reason - I just haven't started using Flakes yet :D Thank you very much for a review. As you may have guessed, I am not very well versed in practical nix packaging. I'll integrate the changes this weekend. |
eef7a24
to
e42ad47
Compare
Kudos, SonarCloud Quality Gate passed! |
Convenience for NixOS / Nixpkgs users,
nix-build
ran in main projectdirectory should build this and create a
result/
symlink pointing at abuilt package.