Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ src/tools/idb_extract
src/tools/jffs2extract
src/tools/lzhs_scanner
src/tools/lzhsenc

result
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small nitpick:

Suggested change
result
/result

33 changes: 33 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{ pkgs ? import <nixpkgs> {} }:

pkgs.stdenv.mkDerivation rec {
pname = "epk2extract";
version = "devel";
Comment on lines +4 to +5
Copy link

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:

Suggested change
pname = "epk2extract";
version = "devel";
name = "epk2extract";


src = ./.;

buildInputs = [
pkgs.cmake
Copy link

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.

pkgs.openssl.dev
Copy link

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.

pkgs.lzo
pkgs.zlib
];

configurePhase = ''
cmake .
'';

buildPhase = ''
make
'';
Comment on lines +15 to +22
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
configurePhase = ''
cmake .
'';
buildPhase = ''
make
'';

If you place cmake in nativeBuildInputs, you get the right setup hooks and won't need this.


installPhase = ''
mkdir -p $out/bin
cd src
cp epk2extract tools/lzhsenc tools/lzhs_scanner tools/idb_extract tools/jffs2extract $out/bin
Comment on lines +25 to +27
Copy link

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):

Suggested change
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


chmod -x ../keys/*
Copy link

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 ../keys/*.key ../keys/*.pem $out/bin
Copy link

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.

'';
}