Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at fix-function-merge 54 lines 1.3 kB view raw
1{ lib 2, stdenv 3, fetchFromGitHub 4, cmake 5, libusb1 6, gtk3 7, pkg-config 8, wrapGAppsHook3 9, withGUI ? false 10}: 11 12let 13 # The Darwin build of stlink explicitly refers to static libusb. 14 libusb1' = if stdenv.isDarwin then libusb1.override { withStatic = true; } else libusb1; 15 16# IMPORTANT: You need permissions to access the stlink usb devices. 17# Add services.udev.packages = [ pkgs.stlink ] to your configuration.nix 18 19in stdenv.mkDerivation rec { 20 pname = "stlink"; 21 version = "1.8.0"; 22 23 src = fetchFromGitHub { 24 owner = "stlink-org"; 25 repo = "stlink"; 26 rev = "v${version}"; 27 sha256 = "sha256-hlFI2xpZ4ldMcxZbg/T5/4JuFFdO9THLcU0DQKSFqrw="; 28 }; 29 30 buildInputs = [ 31 libusb1' 32 ] ++ lib.optionals withGUI [ 33 gtk3 34 ]; 35 nativeBuildInputs = [ 36 cmake 37 ] ++ lib.optionals withGUI [ 38 pkg-config 39 wrapGAppsHook3 40 ]; 41 42 cmakeFlags = [ 43 "-DSTLINK_MODPROBED_DIR=${placeholder "out"}/etc/modprobe.d" 44 "-DSTLINK_UDEV_RULES_DIR=${placeholder "out"}/lib/udev/rules.d" 45 ]; 46 47 meta = with lib; { 48 description = "In-circuit debug and programming for ST-Link devices"; 49 license = licenses.bsd3; 50 platforms = platforms.unix; 51 badPlatforms = platforms.darwin; 52 maintainers = [ maintainers.bjornfor maintainers.rongcuid ]; 53 }; 54}