Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 stdenv,
3 lib,
4 fetchurl,
5 wrapQtAppsHook,
6 dpkg,
7 autoPatchelfHook,
8 qtserialport,
9 qtwebsockets,
10 openssl,
11 libredirect,
12 makeWrapper,
13 gzip,
14 gnutar,
15 nixosTests,
16}:
17
18stdenv.mkDerivation rec {
19 pname = "deconz";
20 version = "2.30.2";
21
22 src = fetchurl {
23 url = "https://deconz.dresden-elektronik.de/ubuntu/beta/deconz-${version}-qt5.deb";
24 sha256 = "sha256-exkelou1xgFEtW3vUqMZFc4AqXruzMRD9n23WmUFr3k=";
25 };
26
27 nativeBuildInputs = [
28 dpkg
29 autoPatchelfHook
30 makeWrapper
31 wrapQtAppsHook
32 ];
33
34 buildInputs = [
35 qtserialport
36 qtwebsockets
37 openssl
38 ];
39
40 unpackPhase = ''
41 runHook preUnpack
42
43 dpkg -x $src ./deconz-src
44
45 runHook postUnpack
46 '';
47
48 installPhase = ''
49 runHook preInstall
50
51 mkdir -p "$out"
52 cp -r deconz-src/* "$out"
53
54 # Flatten /usr and manually merge lib/ and usr/lib/, since mv refuses to.
55 mv "$out/lib" "$out/orig_lib"
56 mv "$out/usr/"* "$out/"
57 mkdir -p "$out/lib/systemd/system/"
58 mv "$out/orig_lib/systemd/system/"* "$out/lib/systemd/system/"
59 rmdir "$out/orig_lib/systemd/system"
60 rmdir "$out/orig_lib/systemd"
61 rmdir "$out/orig_lib"
62 rmdir "$out/usr"
63
64 for f in "$out/lib/systemd/system/"*.service \
65 "$out/share/applications/"*.desktop; do
66 substituteInPlace "$f" \
67 --replace "/usr/" "$out/"
68 done
69
70 for p in "$out/bin/deCONZ" "$out/bin/GCFFlasher_internal.bin"; do
71 wrapProgram "$p" \
72 --set LD_PRELOAD "${libredirect}/lib/libredirect.so" \
73 --set NIX_REDIRECTS "/usr/share=$out/share:/usr/bin=$out/bin" \
74 --prefix PATH : "${
75 lib.makeBinPath [
76 gzip
77 gnutar
78 ]
79 }"
80 done
81
82 runHook postInstall
83 '';
84
85 passthru = {
86 tests = { inherit (nixosTests) deconz; };
87 };
88
89 meta = with lib; {
90 description = "Manage Zigbee network with ConBee, ConBee II or RaspBee hardware";
91 homepage = "https://www.dresden-elektronik.com/wireless/software/deconz.html";
92 license = licenses.unfree;
93 platforms = with platforms; [ "x86_64-linux" ];
94 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
95 maintainers = with maintainers; [ bjornfor ];
96 mainProgram = "deCONZ";
97 };
98}