2021-05-28 09:39:13 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, libusb1
|
|
|
|
, gtk3
|
|
|
|
, pkg-config
|
|
|
|
, wrapGAppsHook
|
|
|
|
, withGUI ? false
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-05-03 17:38:23 +00: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-07 07:45:13 +00:00
|
|
|
# Add services.udev.packages = [ pkgs.stlink ] to your configuration.nix
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-05-03 17:38:23 +00:00
|
|
|
in stdenv.mkDerivation rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "stlink";
|
2024-02-29 20:09:43 +00:00
|
|
|
version = "1.8.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2021-04-26 19:14:03 +00:00
|
|
|
owner = "stlink-org";
|
2020-04-24 23:36:52 +00:00
|
|
|
repo = "stlink";
|
|
|
|
rev = "v${version}";
|
2024-02-29 20:09:43 +00:00
|
|
|
sha256 = "sha256-hlFI2xpZ4ldMcxZbg/T5/4JuFFdO9THLcU0DQKSFqrw=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
buildInputs = [
|
|
|
|
libusb1'
|
|
|
|
] ++ lib.optionals withGUI [
|
|
|
|
gtk3
|
|
|
|
];
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
] ++ lib.optionals withGUI [
|
|
|
|
pkg-config
|
|
|
|
wrapGAppsHook
|
|
|
|
];
|
2021-04-26 19:14:03 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DSTLINK_MODPROBED_DIR=${placeholder "out"}/etc/modprobe.d"
|
|
|
|
"-DSTLINK_UDEV_RULES_DIR=${placeholder "out"}/lib/udev/rules.d"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "In-circuit debug and programming for ST-Link devices";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
platforms = platforms.unix;
|
2024-02-29 20:09:43 +00:00
|
|
|
badPlatforms = platforms.darwin;
|
2020-04-24 23:36:52 +00:00
|
|
|
maintainers = [ maintainers.bjornfor maintainers.rongcuid ];
|
|
|
|
};
|
|
|
|
}
|