Issues packaging deCONZ from a deb package

I’m trying to package deCONZ.

I basically searched on github for existing derivations and tried to modify/use them.

So far I have this:


{ pkgs, stdenv, buildFHSUserEnv, fetchurl, dpkg, qt5, sqlite, hicolor_icon_theme, libcap, libpng,   ... }:
version = "2.05.54";
name = "deconz-${version}";
rec {
  deCONZ-deb = stdenv.mkDerivation {
    #builder = ./;
    inherit name;
    dpkg = dpkg;
    src = fetchurl {
      url = "${name}-qt5.deb";
      sha256 = "0fmywfhgay98n0sm56vjv6sksydgaccfgrmbswswim0dam24j0la";

    dontConfigure = true;
    dontBuild = true;
    dontStrip = true;

    buildInputs = [ dpkg qt5.qtbase qt5.qtserialport qt5.qtwebsockets sqlite hicolor_icon_theme libcap libpng ];

    unpackPhase = "dpkg-deb -x $src .";
    installPhase = ''
      cp -r usr/* .
      cp -r share/deCONZ/plugins/* lib/
      cp -r . $out

  deCONZ = buildFHSUserEnv {
    name = "deCONZ";
    targetPkgs = pkgs: [
    multiPkgs = pkgs: [
    runScript = "deCONZ";

And I try to use it in pkgs/test.nix like so:

  pkgs = import <nixpkgs> { };

    deconz = import ./deconz/default.nix {
      pkgs = pkgs;
      stdenv = pkgs.stdenv;
      buildFHSUserEnv = pkgs.buildFHSUserEnv;
      fetchurl = pkgs.fetchurl;
      dpkg = pkgs.dpkg;
      qt5 = pkgs.qt5;
      sqlite = pkgs.sqlite;
      hicolor_icon_theme = pkgs.hicolor_icon_theme;
      libcap = pkgs.libcap;
      libpng = pkgs.libpng;

When I run nix-env -f test.nix -i -A deconz it seems to install the binary in my current nix-profile as it shows up on my path:

 ~ which deCONZ                                                                                                             
 ~ ls -l  $(which deCONZ)                                                                                                   
lrwxrwxrwx 1 deni deni 61 Jan  1  1970 /home/deni/.nix-profile/bin/deCONZ -> /nix/store/bll4p4bafn91jw5sfm4sia86s52rsk97-deCONZ/bin/deCONZ

However when I try to run the command I get the following error:

 ~ deCONZ                                                                                                                   
** Message: 10:50:07.067: Requires Linux version >= 3.19 built with CONFIG_USER_NS
** Message: 10:50:07.073: Run: sudo sysctl -w kernel.unprivileged_userns_clone=1

** (process:18940): ERROR **: 10:50:07.074: main: unshare: No space left on device
[1]    18508 trace trap  deCONZ

Now, I already set kernel.unprivileged_userns_clone=1 because I needed it for nix-channel --update. Tried resetting it but it didn’t help.
I’m trying this on Debian with nix 2.3.1. Eventually, I wanna run this on NixOS but haven’t gotten that far (with regards to configuring a service and running it in headless mode because I have no X installed on my nixOS machine).

I’m pretty sure this has something to do with buildFHSUserEnv but I don’t really understand it very well. I read about it here but don’t really know how to debug. Any advice is appreciated.

You can try my expression, it uses librewrite instead of buildFHSUserEnv:

(I first looked at nixpkgs github issue tracker, found nothing related to deCONZ, then wrote my expresison and then found some other expressions misc places on github.)

I want to run deCONZ as a service, but faced some problems that I reported upstream. If/when having a working service we should add it to NixOS :slight_smile: (I have a WIP nixos module for deCONZ locally.)

1 Like

Hey @bjornfor
I found your nix expression after I posted this. I tried replacing default.nix from above with the one from your repo. I updated test.nix to pass in the correct arguments after which I ran:

nix-env -f test.nix -i -A deconz

It seems to have completed installing as there is a deCONZ link in my nix profile. However, when I try running the deCONZ command this is what I get:

qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

[1]    5629 abort      deCONZ

I think the problem is in how the expression is being “called”.

Try using this in your test.nix:

{ pkgs ? import <nixpkgs> {} }:

  deconz = pkgs.qt5.callPackage ./default.nix {};
1 Like

Thank you @bjornfor this does it!

Now that I’m able to build and run the application I’m also looking to run it as a service. I’d be happy to help if I can to get this added to NixOS. Let me know.

I’d be interested to see your WIP module as well.

@deni: Good!

I pushed my deconz module here:

I think part of my problems with deconz auth is that I’ve been developing this on localhost. I think if it runs on a separate device, on port 80, it will work much better.

4 years later and I finally wrote a nixpkgs PR: deconz: init at 2.23.00 by bjornfor · Pull Request #253885 · NixOS/nixpkgs · GitHub

1 Like