summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/im/imsprog/package.nix
blob: 66cb93caa68c8cf1c2ab57732f76cdd93fd3a5e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{
  lib,
  stdenv,
  fetchFromGitHub,
  cmake,
  makeWrapper,
  pkg-config,
  bash,
  libusb1,
  qt5,
  wget,
  zenity,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "imsprog";
  version = "1.8.6";

  src = fetchFromGitHub {
    owner = "bigbigmdm";
    repo = "IMSProg";
    tag = "v${finalAttrs.version}";
    hash = "sha256-wYzhOQfkuXgc3fxYlkx284gu5gIYUH5SppM02WD1YWI=";
  };

  strictDeps = true;

  nativeBuildInputs = [
    cmake
    makeWrapper
    pkg-config
    qt5.wrapQtAppsHook
    qt5.qttools
  ];

  buildInputs = [
    bash # for patching the shebang in bin/IMSProg_database_update
    libusb1
    qt5.qtbase
    qt5.qtwayland
  ];

  # change default hardcoded path for chip database file, udev rules et al
  postPatch = ''
    while IFS= read -r -d "" file ; do
      substituteInPlace "$file" \
        --replace-quiet '/usr/bin/' "$out/bin/" \
        --replace-quiet '/usr/lib/' "$out/lib/" \
        --replace-quiet '/usr/share/' "$out/share/"
    done < <(grep --files-with-matches --null --recursive '/usr/' .)
  '';

  postFixup = ''
    wrapProgram $out/bin/IMSProg_database_update \
      --prefix PATH : "${
        lib.makeBinPath [
          wget
          zenity
        ]
      }"
  '';

  doInstallCheck = true;

  meta = {
    changelog = "https://github.com/bigbigmdm/IMSProg/releases/tag/v${finalAttrs.version}";
    description = "Free I2C, MicroWire and SPI EEPROM/Flash chip programmer tool for CH341A device";
    homepage = "https://github.com/bigbigmdm/IMSProg";
    license = with lib.licenses; [
      gpl3Plus
      gpl2Plus
      lgpl21Only
    ];
    mainProgram = "IMSProg";
    maintainers = with lib.maintainers; [ wucke13 ];
    platforms = lib.platforms.unix;
  };
})