about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/misc/stlink/default.nix
blob: 2fbb60a0ddcce2e06d200fa4b61fdb519951b445 (plain) (blame)
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
{ lib
, stdenv
, fetchFromGitHub
, cmake
, libusb1
, gtk3
, pkg-config
, wrapGAppsHook
, withGUI ? false
}:

let
  # The Darwin build of stlink explicitly refers to static libusb.
  libusb1' = if stdenv.isDarwin then libusb1.override { withStatic = true; } else libusb1;

# IMPORTANT: You need permissions to access the stlink usb devices.
# Add services.udev.packages = [ pkgs.stlink ] to your configuration.nix

in stdenv.mkDerivation rec {
  pname = "stlink";
  version = "1.7.0";

  src = fetchFromGitHub {
    owner = "stlink-org";
    repo = "stlink";
    rev = "v${version}";
    sha256 = "03xypffpbp4imrczbxmq69vgkr7mbp0ps9dk815br5wwlz6vgygl";
  };

  buildInputs = [
    libusb1'
  ] ++ lib.optionals withGUI [
    gtk3
  ];
  nativeBuildInputs = [
    cmake
  ] ++ lib.optionals withGUI [
    pkg-config
    wrapGAppsHook
  ];

  cmakeFlags = [
    "-DSTLINK_MODPROBED_DIR=${placeholder "out"}/etc/modprobe.d"
    "-DSTLINK_UDEV_RULES_DIR=${placeholder "out"}/lib/udev/rules.d"
  ];

  meta = with lib; {
    description = "In-circuit debug and programming for ST-Link devices";
    license = licenses.bsd3;
    platforms = platforms.unix;
    maintainers = [ maintainers.bjornfor maintainers.rongcuid ];
  };
}