2019-08-05 16:58:22 +01:00
|
|
|
{ stdenv, fetchFromGitHub, cmake, libusb1 }:
|
2013-02-23 11:05:22 +00:00
|
|
|
|
2020-04-24 22:55:18 +01: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.
|
2017-02-12 02:44:29 +00:00
|
|
|
# Add services.udev.pkgs = [ pkgs.stlink ] to your configuration.nix
|
2013-02-23 11:05:22 +00:00
|
|
|
|
2020-04-24 22:55:18 +01:00
|
|
|
in stdenv.mkDerivation rec {
|
2019-08-13 22:52:01 +01:00
|
|
|
pname = "stlink";
|
2020-02-27 16:40:28 +00:00
|
|
|
version = "1.6.0";
|
2013-02-23 11:05:22 +00:00
|
|
|
|
2019-08-05 16:58:22 +01:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "texane";
|
|
|
|
repo = "stlink";
|
2020-02-27 16:40:28 +00:00
|
|
|
rev = "v${version}";
|
2020-02-25 01:16:26 +00:00
|
|
|
sha256 = "1mlkrxjxg538335g59hjb0zc739dx4mhbspb26z5gz3lf7d4xv6x";
|
2013-02-23 11:05:22 +00:00
|
|
|
};
|
|
|
|
|
2020-04-24 22:56:39 +01:00
|
|
|
buildInputs = [ libusb1' ];
|
|
|
|
nativeBuildInputs = [ cmake ];
|
2017-02-12 02:44:29 +00:00
|
|
|
patchPhase = ''
|
|
|
|
sed -i 's@/etc/udev/rules.d@$ENV{out}/etc/udev/rules.d@' CMakeLists.txt
|
|
|
|
sed -i 's@/etc/modprobe.d@$ENV{out}/etc/modprobe.d@' CMakeLists.txt
|
|
|
|
'';
|
|
|
|
preInstall = ''
|
|
|
|
mkdir -p $out/etc/udev/rules.d
|
|
|
|
mkdir -p $out/etc/modprobe.d
|
|
|
|
'';
|
2013-02-23 11:05:22 +00:00
|
|
|
|
2013-05-20 18:33:18 +01:00
|
|
|
meta = with stdenv.lib; {
|
2013-02-23 11:05:22 +00:00
|
|
|
description = "In-circuit debug and programming for ST-Link devices";
|
2013-05-20 18:33:18 +01:00
|
|
|
license = licenses.bsd3;
|
2019-05-01 17:15:33 +01:00
|
|
|
platforms = platforms.unix;
|
2017-02-12 02:44:29 +00:00
|
|
|
maintainers = [ maintainers.bjornfor maintainers.rongcuid ];
|
2013-02-23 11:05:22 +00:00
|
|
|
};
|
|
|
|
}
|