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