Skip to content

Commit 3dfde49

Browse files
committed
chore(nix): add partclone dependencies to nix env
1 parent 93cee8d commit 3dfde49

File tree

4 files changed

+134
-38
lines changed

4 files changed

+134
-38
lines changed

docs/formats.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ unblob supports more than 30 formats. You can see their code in
4141
[dmg-handler]: https://github.com/onekey-sec/unblob/blob/main/unblob/handlers/archive/dmg.py
4242
[dmg-extractor]: https://github.com/onekey-sec/unblob/blob/3008039881a0434deb75962e7999b7e35aca8271/unblob/handlers/archive/dmg.py#L67-L69
4343
[partclone-handler]: https://github.com/onekey-sec/unblob/blob/main/unblob/handlers/archive/partclone.py
44-
[partclone-extractor]:
44+
[partclone-extractor]: https://github.com/onekey-sec/unblob/blob/b21b6dc291583af6b7ec9b7c3d63ee8302328841/python/unblob/handlers/archive/partclone.py#L44
4545
[rar-handler]: https://github.com/onekey-sec/unblob/blob/main/unblob/handlers/archive/rar.py
4646
[rar-extractor]: https://github.com/onekey-sec/unblob/blob/3008039881a0434deb75962e7999b7e35aca8271/unblob/handlers/archive/rar.py#L32
4747
[7zip-handler]: https://github.com/onekey-sec/unblob/blob/main/unblob/handlers/archive/sevenzip.py

overlay.nix

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,5 @@ final: prev:
88
nativeCheckInputs = (super.nativeCheckInputs or [ ]) ++ [ final.which ];
99
});
1010

11-
unblob =
12-
let
13-
pyproject_toml = (builtins.fromTOML (builtins.readFile ./pyproject.toml));
14-
version = pyproject_toml.project.version;
15-
in
16-
(prev.unblob.override { e2fsprogs = final.e2fsprogs-nofortify; }).overridePythonAttrs (super: rec {
17-
inherit version;
18-
19-
src = final.nix-filter {
20-
root = ./.;
21-
include = [
22-
"Cargo.lock"
23-
"Cargo.toml"
24-
"pyproject.toml"
25-
"python"
26-
"rust"
27-
"tests"
28-
"README.md"
29-
];
30-
};
31-
32-
# remove this when packaging changes are upstreamed
33-
cargoDeps = final.rustPlatform.importCargoLock {
34-
lockFile = ./Cargo.lock;
35-
};
36-
37-
nativeBuildInputs = with final.rustPlatform; [
38-
cargoSetupHook
39-
maturinBuildHook
40-
];
41-
42-
# override disabling of 'test_all_handlers[filesystem.extfs]' from upstream
43-
pytestFlagsArray = [
44-
"--no-cov"
45-
];
46-
});
11+
unblob = final.callPackage ./package.nix { };
4712
}

package.nix

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
{
2+
lib,
3+
python3,
4+
fetchFromGitHub,
5+
makeWrapper,
6+
e2fsprogs-nofortify,
7+
jefferson,
8+
lz4,
9+
lziprecover,
10+
lzop,
11+
p7zip,
12+
nix-filter,
13+
sasquatch,
14+
sasquatch-v4be,
15+
simg2img,
16+
ubi_reader,
17+
unar,
18+
partclone,
19+
zstd,
20+
versionCheckHook,
21+
rustPlatform,
22+
}:
23+
24+
let
25+
# These dependencies are only added to PATH
26+
runtimeDeps = [
27+
e2fsprogs-nofortify
28+
jefferson
29+
lziprecover
30+
lzop
31+
p7zip
32+
sasquatch
33+
sasquatch-v4be
34+
ubi_reader
35+
partclone
36+
simg2img
37+
unar
38+
zstd
39+
lz4
40+
];
41+
pyproject_toml = (builtins.fromTOML (builtins.readFile ./pyproject.toml));
42+
version = pyproject_toml.project.version;
43+
in
44+
python3.pkgs.buildPythonApplication rec {
45+
pname = "unblob";
46+
pyproject = true;
47+
disabled = python3.pkgs.pythonOlder "3.9";
48+
inherit version;
49+
src = nix-filter {
50+
root = ./.;
51+
include = [
52+
"Cargo.lock"
53+
"Cargo.toml"
54+
"pyproject.toml"
55+
"python"
56+
"rust"
57+
"tests"
58+
"README.md"
59+
];
60+
};
61+
62+
strictDeps = true;
63+
64+
build-system = with python3.pkgs; [ poetry-core ];
65+
66+
dependencies = with python3.pkgs; [
67+
arpy
68+
attrs
69+
click
70+
cryptography
71+
dissect-cstruct
72+
lark
73+
lief.py
74+
python3.pkgs.lz4 # shadowed by pkgs.lz4
75+
plotext
76+
pluggy
77+
pyfatfs
78+
pyperscan
79+
python-magic
80+
pyzstd
81+
rarfile
82+
rich
83+
structlog
84+
treelib
85+
unblob-native
86+
];
87+
88+
cargoDeps = rustPlatform.importCargoLock {
89+
lockFile = ./Cargo.lock;
90+
};
91+
92+
nativeBuildInputs = with rustPlatform; [
93+
cargoSetupHook
94+
maturinBuildHook
95+
makeWrapper
96+
];
97+
98+
# These are runtime-only CLI dependencies, which are used through
99+
# their CLI interface
100+
pythonRemoveDeps = [
101+
"jefferson"
102+
"ubi-reader"
103+
];
104+
105+
pythonImportsCheck = [ "unblob" ];
106+
107+
makeWrapperArgs = [
108+
"--prefix PATH : ${lib.makeBinPath runtimeDeps}"
109+
];
110+
111+
nativeCheckInputs =
112+
with python3.pkgs;
113+
[
114+
pytestCheckHook
115+
pytest-cov
116+
versionCheckHook
117+
]
118+
++ runtimeDeps;
119+
120+
versionCheckProgramArg = "--version";
121+
122+
pytestFlagsArray = [
123+
"--no-cov"
124+
];
125+
126+
passthru = {
127+
# helpful to easily add these to a nix-shell environment
128+
inherit runtimeDeps;
129+
};
130+
131+
}

shell.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ let
44
./flake.lock
55
./flake.nix
66
./overlay.nix
7-
./nix
7+
./package.nix
88
];
99

1010
lock = builtins.fromJSON (builtins.readFile ./flake.lock);

0 commit comments

Comments
 (0)