1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 rustPlatform,
6 pkg-config,
7 autoPatchelfHook,
8 blisp,
9 dfu-util,
10 fontconfig,
11 glib,
12 gtk3,
13 openssl,
14 systemd,
15 libGL,
16 libxkbcommon,
17 nix-update-script,
18 wayland,
19}:
20rustPlatform.buildRustPackage (finalAttrs: {
21 pname = "pineflash";
22 version = "0.5.5";
23
24 src = fetchFromGitHub {
25 owner = "Spagett1";
26 repo = "pineflash";
27 tag = finalAttrs.version;
28 hash = "sha256-4tcwEok36vuXbtlZNUkLNw1kHFQPBEJM/gWRhRWNLPg=";
29 };
30
31 cargoHash = "sha256-OgUWOtqgGCRNYCrdMa8IAfxbbYqv+1WwubvfYybuAQU=";
32
33 nativeBuildInputs = [
34 pkg-config
35 ]
36 ++ lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook;
37
38 buildInputs = [
39 blisp
40 dfu-util
41 fontconfig
42 glib
43 gtk3
44 openssl
45 systemd
46 ];
47
48 runtimeDependencies = [
49 libGL
50 libxkbcommon
51 wayland
52 ];
53
54 postPatch = ''
55 substituteInPlace src/submodules/flash.rs \
56 --replace-fail 'let command = Command::new("pkexec")' 'let command = Command::new("/run/wrappers/bin/pkexec")'
57 ''
58 + lib.optionalString stdenv.hostPlatform.isLinux ''
59 substituteInPlace src/submodules/flash.rs \
60 --replace-fail 'let blisppath = "blisp";' 'let blisppath = "${lib.getExe blisp}";' \
61 --replace-fail 'let dfupath = "dfu-util";' 'let dfupath = "${lib.getExe' dfu-util "dfu-util"}";'
62 ''
63 + lib.optionalString stdenv.hostPlatform.isDarwin ''
64 substituteInPlace src/submodules/flash.rs \
65 --replace-fail 'Command::new("blisp")' 'Command::new("${lib.getExe blisp}")' \
66 --replace-fail 'Command::new("dfu-util")' 'Command::new("${lib.getExe' dfu-util "dfu-util"}")'
67 '';
68
69 postInstall = ''
70 mkdir -p "$out/share/applications"
71 cp ./assets/Pineflash.desktop "$out/share/applications/Pineflash.desktop"
72 mkdir -p "$out/share/pixmaps"
73 cp ./assets/pine64logo.png "$out/share/pixmaps/pine64logo.png"
74 '';
75
76 passthru = {
77 updateScript = nix-update-script { };
78 };
79
80 meta = {
81 description = "GUI tool to flash IronOS to the Pinecil V1 and V2";
82 homepage = "https://github.com/Spagett1/pineflash";
83 changelog = "https://github.com/Spagett1/pineflash/releases/tag/${finalAttrs.version}";
84 license = lib.licenses.gpl2Only;
85 maintainers = with lib.maintainers; [
86 acuteaangle
87 ];
88 mainProgram = "pineflash";
89 };
90})