summary refs log tree commit diff
path: root/pkgs/servers/brickd/default.nix
blob: ee8925e117099629f8aee033a1ccd23476017013 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{ stdenv, fetchgit, libusb, pkgconfig, pmutils, udev} :

let

version = "2.1.1";
daemonlib = fetchgit {
    url = "https://github.com/Tinkerforge/daemonlib.git";
    rev = "refs/tags/brickd-${version}";
    sha256 = "097kaz7d0rzg0ijvcna3y620k3m5fgxpqsac5gbhah8pd7vlj1a4";
  };

in

stdenv.mkDerivation {
  pname = "brickd";
  inherit version;

  src = fetchgit {
    url = "git://github.com/Tinkerforge/brickd.git";
    rev = "refs/tags/v${version}";
    sha256 = "0m2q01sbgf8z4559jpr6k3jivb8x98vxv1fhgx8nfcjbwz1q83gb";
  };

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [ libusb pmutils udev ];

  # shell thing didn't work so i replaced it using nix
  prePatch = ''
    substituteInPlace src/brickd/Makefile --replace 'PKG_CONFIG := $(shell which pkg-config 2> /dev/null)' "PKG_CONFIG := $pkgconfig/bin/pkg_config";
  '';

  buildPhase = ''
    export
    # build the brickd binary
    mkdir src/daemonlib
    cp -r ${daemonlib}/* src/daemonlib
    cd src/brickd
    make

    # build and execute the unit tests
    cd ../tests
    make
    for i in array_test base58_test node_test putenv_test queue_test sha1_test; do
      echo "running unit test $i:"
      ./$i
    done
  '';

  installPhase = ''
    cd ../brickd
    mkdir -p $out/bin
    cp brickd $out/bin/brickd
  '';

  meta = {
    homepage = https://www.tinkerforge.com/;
    description = "A daemon (or service on Windows) that acts as a bridge between the Bricks/Bricklets and the API bindings for the different programming languages";
    maintainers = [ stdenv.lib.maintainers.qknight ];
    license = stdenv.lib.licenses.gpl2;
    platforms = stdenv.lib.platforms.all;
  };
}