nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, stdenv
3, fetchFromGitHub
4, pythonRelaxDepsHook
5, python3
6, snagboot
7, testers
8, gitUpdater
9}:
10
11python3.pkgs.buildPythonApplication rec {
12 pname = "snagboot";
13 version = "1.0";
14 format = "pyproject";
15
16 src = fetchFromGitHub {
17 owner = "bootlin";
18 repo = "snagboot";
19 rev = "v${version}";
20 hash = "sha256-QqGeELm2seX3tIKQvuXp9VsNDah+m9FNcaEVk6TMP0U=";
21 };
22
23 passthru = {
24 updateScript = gitUpdater {
25 rev-prefix = "v";
26 ignoredVersions = ".(rc|beta).*";
27 };
28
29 tests.version = testers.testVersion {
30 package = snagboot;
31 command = "snagrecover --version";
32 version = "v${version}";
33 };
34 };
35
36 nativeBuildInputs = [
37 pythonRelaxDepsHook
38 ];
39
40 pythonRemoveDeps = [
41 "pylibfdt"
42 "swig"
43 ];
44
45 propagatedBuildInputs = with python3.pkgs; [
46 setuptools
47 pyusb
48 pyserial
49 hid
50 crccheck
51 six
52 xmodem
53 pyyaml
54 libfdt
55 tftpy
56 ];
57
58 postInstall = lib.optionalString stdenv.isLinux ''
59 rules="src/snagrecover/80-snagboot.rules"
60 if [ ! -f "$rules" ]; then
61 echo "$rules is missing, must update the Nix file."
62 exit 1
63 fi
64
65 mkdir -p "$out/lib/udev/rules.d"
66 cp "$rules" "$out/lib/udev/rules.d/80-snagboot.rules"
67 '';
68
69 # There are no tests
70 doCheck = false;
71
72 meta = {
73 homepage = "https://github.com/bootlin/snagboot";
74 description = "Generic recovery and reflashing tool for embedded platforms";
75 license = lib.licenses.gpl2;
76 maintainers = with lib.maintainers; [ otavio ];
77 };
78}