nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 libusb1,
6 pkg-config,
7 pmutils,
8 udev,
9}:
10
11let
12 version = "2.1.1";
13 daemonlib = fetchFromGitHub {
14 owner = "Tinkerforge";
15 repo = "daemonlib";
16 rev = "brickd-${version}";
17 sha256 = "sha256-0HhuC4r1S4NJa2FSJa7+fNCfcoRTBckikYbGSE+2FbE=";
18 };
19in
20
21stdenv.mkDerivation {
22 pname = "brickd";
23 inherit version;
24
25 src = fetchFromGitHub {
26 owner = "Tinkerforge";
27 repo = "brickd";
28 rev = "v${version}";
29 sha256 = "sha256-6w2Ew+dLMmdRf9CF3TdKHa0d5ZgmX5lKIR+5t3QAWFQ=";
30 };
31
32 nativeBuildInputs = [ pkg-config ];
33 buildInputs = [
34 libusb1
35 pmutils
36 udev
37 ];
38
39 # shell thing didn't work so i replaced it using nix
40 prePatch = ''
41 substituteInPlace src/brickd/Makefile --replace 'PKG_CONFIG := $(shell which pkg-config 2> /dev/null)' "PKG_CONFIG := $pkgconfig/bin/pkg_config";
42 '';
43
44 buildPhase = ''
45 # build the brickd binary
46 mkdir src/daemonlib
47 cp -r ${daemonlib}/* src/daemonlib
48 substituteInPlace src/daemonlib/utils.{c,h} \
49 --replace "_GNU_SOURCE" "__GLIBC__"
50 cd src/brickd
51 make
52
53 # build and execute the unit tests
54 cd ../tests
55 make
56 for i in array_test base58_test node_test putenv_test queue_test sha1_test; do
57 echo "running unit test $i:"
58 ./$i
59 done
60 '';
61
62 installPhase = ''
63 cd ../brickd
64 mkdir -p $out/bin
65 cp brickd $out/bin/brickd
66 '';
67
68 meta = {
69 homepage = "https://www.tinkerforge.com/";
70 description = "Daemon (or service on Windows) that acts as a bridge between the Bricks/Bricklets and the API bindings for the different programming languages";
71 maintainers = [ lib.maintainers.qknight ];
72 license = lib.licenses.gpl2Plus;
73 platforms = lib.platforms.all;
74 mainProgram = "brickd";
75 };
76}