2021-01-23 19:26:19 +07:00
|
|
|
{ lib, stdenv, fetchFromGitHub, cmake, libusb1 }:
|
2013-02-23 12:05:22 +01:00
|
|
|
|
2020-04-24 23:55:18 +02:00
|
|
|
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.
|
2020-12-04 13:53:17 +01:00
|
|
|
# Add services.udev.packages = [ pkgs.stlink ] to your configuration.nix
|
2013-02-23 12:05:22 +01:00
|
|
|
|
2020-04-24 23:55:18 +02:00
|
|
|
in stdenv.mkDerivation rec {
|
2019-08-13 21:52:01 +00:00
|
|
|
pname = "stlink";
|
2020-08-12 21:16:20 +02:00
|
|
|
version = "1.7.0";
|
2013-02-23 12:05:22 +01:00
|
|
|
|
2019-08-05 23:58:22 +08:00
|
|
|
src = fetchFromGitHub {
|
2020-08-12 21:16:20 +02:00
|
|
|
owner = "stlink-org";
|
2019-08-05 23:58:22 +08:00
|
|
|
repo = "stlink";
|
2020-02-27 08:40:28 -08:00
|
|
|
rev = "v${version}";
|
2020-08-12 21:16:20 +02:00
|
|
|
sha256 = "03xypffpbp4imrczbxmq69vgkr7mbp0ps9dk815br5wwlz6vgygl";
|
2013-02-23 12:05:22 +01:00
|
|
|
};
|
|
|
|
|
|
2020-04-24 23:56:39 +02:00
|
|
|
buildInputs = [ libusb1' ];
|
|
|
|
|
nativeBuildInputs = [ cmake ];
|
2020-08-12 21:16:20 +02:00
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
|
"-DSTLINK_MODPROBED_DIR=${placeholder "out"}/etc/modprobe.d"
|
|
|
|
|
"-DSTLINK_UDEV_RULES_DIR=${placeholder "out"}/lib/udev/rules.d"
|
|
|
|
|
];
|
2013-02-23 12:05:22 +01:00
|
|
|
|
2021-01-23 19:26:19 +07:00
|
|
|
meta = with lib; {
|
2013-02-23 12:05:22 +01:00
|
|
|
description = "In-circuit debug and programming for ST-Link devices";
|
2013-05-20 19:33:18 +02:00
|
|
|
license = licenses.bsd3;
|
2019-05-02 01:15:33 +09:00
|
|
|
platforms = platforms.unix;
|
2017-02-11 18:44:29 -08:00
|
|
|
maintainers = [ maintainers.bjornfor maintainers.rongcuid ];
|
2013-02-23 12:05:22 +01:00
|
|
|
};
|
|
|
|
|
}
|