New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
openzwave & pythonPackages.python_openzwave: init at 20180404 and 0.4.4 #38577
Conversation
cc @dotlambda @f-breidenstein maybe? |
01738ec
to
7d07895
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain what /etc/openzwave
usually contains?
Did you test that this actually works with Home Assistant?
, udev }: | ||
|
||
let | ||
version = "2018-04-04"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not a stable version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the latest stable is V1.5 and was relaseaed 2016-08-15. And the repository seems to be quite active since then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like almost all distros package 1.5: https://repology.org/metapackage/openzwave/versions.
But pip install python_openzwave
installs from master by default: https://github.com/OpenZWave/python-openzwave#python-openzwave-04x-is-here-.
So I guess using an unstable version should be fine.
You could however ask them what they want distributions to do on their mailing list.
makeFlagsArray+=("DESTDIR=$out") | ||
makeFlagsArray+=("PREFIX=$out") | ||
makeFlagsArray+=("pkgconfigdir=lib/pkgconfig") | ||
makeFlagsArray+=("sysconfigdir=etc/openzwave") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can set this in makeFlags
, no need to use preBuild
. See https://nixos.org/nixpkgs/manual/#build-phase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is much nicer, thanks 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem to work like the docs suggests:
makeFlags = [
"DESTDIR=$(out)"
"PREFIX=$(out)"
"pkgconfigdir=lib/pkgconfig"
"sysconfigdir=etc/openzwave"
];
Doesn't build and it seems like the issue is with $out
because it outputs this:
build flags: SHELL=/nix/store/q1g0rl8zfmz7r371fp5p42p4acmv297d-bash-4.4-p19/bin/bash DESTDIR=\$\(out\) PREFIX=\$\(out\) pkgconfigdir=lib/pkgconfig sysconfigdir=etc/openzwave
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a problem sometimes. Try without parantheses or use "DESTDIR=\${out}"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't help at all :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried myself and it gives me a different error when leaving out parantheses: mv: cannot stat '/nix/store/nhy5v0l6yccgi2wfp01d457dp9g6ql9w-openzwave-2018-04-04//nix/store/nhy5v0l6yccgi2wfp01d457dp9g6ql9w-openzwave-2018-04-04/bin': No such file or directory
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's the fixupPhase. If it's not getting the prefix and destdir it just don't put any files in the store path.
|
||
preBuild = '' | ||
makeFlagsArray+=("DESTDIR=$out") | ||
makeFlagsArray+=("PREFIX=$out") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try removing this line and you shouldn't need the fixup anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing that created a whole range of other issues, because there's a thing that doesn't respect the DESTDIR
...
So currently it creates:
/nix/store/xyz-openzwave-2018-04-04/lib/pkgconfig/libopenzwave.pc
/nix/store/xyz-openzwave-2018-04-04/nix/store/xyz-openzwave-2018-04-04/<rest-of-the-files>
I haven't found a good workaround for that :/
But I can dig some more now when I have gotten some sleep. I've might also been very tierd and fuzzy during the late hours yesterday and don't remember all the details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've gone through all the things now.
I've managed to set PREFIX=
(as in empty string to not get the default /usr/local/bin
).
And got rid of most of fixup but had to patch the pkgconfig-file so the python library can be built.
I have tested it with the python library on x86_64 with home assistant as well. So at the moment it works and is slightly less ugly :)
|
||
meta = with stdenv.lib; { | ||
description = "C++ library to control Z-Wave Networks via a USB Z-Wave Controller"; | ||
homepage = https://github.com/OpenZWave/open-zwave; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe http://www.openzwave.net/ instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've honestly missed that that one exists because it's not coming up top when I've been doing searches :D
@dotlambda |
@dotlambda As for your other question:
Yes, I have it running here on my desktop as well as a raspberry pi. I had to change one little thing in the home-assistant derivation (for some depenedency), and had to add some configuration myself to the config file. Diff of home-assistant: diff --git a/pkgs/servers/home-assistant/default.nix b/pkgs/servers/home-assistant/default.nix
index 75f8b309a40..e1814317463 100644
--- a/pkgs/servers/home-assistant/default.nix
+++ b/pkgs/servers/home-assistant/default.nix
@@ -72,6 +72,7 @@ in with py.pkgs; buildPythonApplication rec {
propagatedBuildInputs = [
# From setup.py
requests pyyaml pytz pip jinja2 voluptuous typing aiohttp async-timeout astral certifi attrs
+ pydispatcher
# From http, frontend and recorder components
sqlalchemy aiohttp-cors hass-frontend
] ++ componentBuildInputs ++ extraBuildInputs; configuration: # Enable Home Assistant, open port and add the hass user to the dialout group
services.home-assistant.enable = true;
services.home-assistant.package = pkgs.home-assistant.override {
extraPackages = ps: [ pkgs.python36Packages.python_openzwave ];
};
networking.firewall.allowedTCPPorts = [ 8123 ];
users.extraUsers.hass.extraGroups = [ "dialout" ]; Yaml for home-assistant: zwave:
usb_path: /dev/serial/by-id/usb-0658_0200-if00
config_path: /nix/store/dlgdch7iwdd6ky4z1b4wpzrn1mg8w4i5-openzwave-2018-04-04/etc/openzwave/ As you can see it's not perfect, especially not the part that it's required to configure the config_path. It's an optional parameter so it looks in default places. I've yet to figure out how to set these defaults. First I thought that I did by patching |
makeFlagsArray+=("PREFIX=") | ||
makeFlagsArray+=("pkgconfigdir=lib/pkgconfig") | ||
makeFlagsArray+=("sysconfigdir=etc/openzwave") | ||
''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dotlambda At least I've got "rid" of the prefix and lots of file moving in the fixup, but still not sure how to use makeFlags
... At least it's quite alot cleaner overall now....
That shoud be |
services.home-assistant.package = pkgs.home-assistant.override {
extraPackages = ps: [ python_openzwave ];
extraComponents = [ "zwave" ];
}; results in: and if I remove my patch from home-assistant/default.nix and use this configuration: # Enable Home Assistant, open port and add the hass user to the dialout group
services.home-assistant.enable = true;
services.home-assistant.package = pkgs.home-assistant.override {
extraPackages = ps: [ pkgs.python36Packages.python_openzwave ];
extraComponents = [ "zwave" ];
};
networking.firewall.allowedTCPPorts = [ 8123 ];
users.extraUsers.hass.extraGroups = [ "dialout" ]; It just doesn't work inside of home-assistant, and I can find the following error in the debug log:
|
You need to copy exactly that: |
Oh, yeah, that did work :) |
pkgs/top-level/all-packages.nix
Outdated
@@ -20532,6 +20532,8 @@ with pkgs; | |||
|
|||
moltengamepad = callPackage ../misc/drivers/moltengamepad { }; | |||
|
|||
openzwave = callPackage ../misc/drivers/openzwave { }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this belongs in pkgs/development/libraries
.
How about so?
@etu Please also try fixing the Maybe @peterhoeg or @FRidh want to have a look at this? I'm certainly not an expert when it comes to C libraries. |
@etu I added a commit which should fix |
names.append(req[len('python-'):]) | ||
for name in names: | ||
# treat "-" and "_" equally | ||
name = re.sub('[-_]', '[-_]', name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replacement is a regex as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, because I need to replace both, - and _, at the same time. I don't think string.replace()
can do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could do
name = name.replace('_', '-')
name = name.replace('-', '[-_]')
@dotlambda Re fontconfig: Here I have a build log of openzwave and python_openzwave: https://gist.github.com/etu/6bdba2f432a839566e6806b5d72e3773 -- which warnings do you refer to? |
@dotlambda
That resulted in a python error log from home-assistant that complaints about a missing python module named |
Maybe that error only appears when enabling sandboxing. |
@dotlambda Seems so, I can reproduce it by enabling sandboxing. |
@etu I investigated why |
This patch does get rid of the fontconfig warnings, but I'm not sure where to put the environment variables because preInstall feels like the wrong place. diff --git a/pkgs/development/libraries/openzwave/default.nix b/pkgs/development/libraries/openzwave/default.nix
index 0d5feae2419..3c18849f1c5 100644
--- a/pkgs/development/libraries/openzwave/default.nix
+++ b/pkgs/development/libraries/openzwave/default.nix
@@ -1,5 +1,5 @@
{ stdenv, fetchFromGitHub
-, doxygen, libxml2, git, which, pkgconfig, graphviz-nox
+, doxygen, libxml2, git, which, pkgconfig, graphviz-nox, fontconfig
, udev }:
let
@@ -15,7 +15,7 @@ in stdenv.mkDerivation rec {
sha256 = "0yby8ygzjn5zp5vhysxaadbzysqanwd2zakz379299qs454pr2h9";
};
- nativeBuildInputs = [ doxygen libxml2 git which pkgconfig graphviz-nox ];
+ nativeBuildInputs = [ doxygen libxml2 git which pkgconfig graphviz-nox fontconfig ];
buildInputs = [ udev ];
installFlags = [
@@ -26,6 +26,9 @@ in stdenv.mkDerivation rec {
preInstall = ''
installFlagsArray+=("DESTDIR=$out")
+
+ export FONTCONFIG_FILE=${fontconfig.out}/etc/fonts/fonts.conf
+ export FONTCONFIG_PATH=${fontconfig.out}/etc/fonts/
'';
postPatch = '' I will try your change. |
You can make these a part of the Nix expression, i.e.
|
@dotlambda Oh, ok. Rebased and pushed. I've tested that change in home-assistant/default.nix and no such luck. Now it's missing |
@dotlambda I've just confirmed that my patch here: https://github.com/NixOS/nixpkgs/pull/38577/files#diff-588a05cff755242c814f80436a1184faR23 Works properly in home-assistant. So one doesn't need to configure that. That makes everything better I'd say 😄 |
Sorry about being late to the party. Please don't merge this yet, I have a few comments. |
I made a few changes to address a few issues - you can see them here: peterhoeg/nixpkgs@75aaa71...peterhoeg:zw
|
@peterhoeg Oh, nice. I'm gonna test through it all tonight (in like 12-13 hours when I get home from work and other things). You can push this to my branch if you want :) |
Pushed. You probably want to squash those commits into the relevant commits on your side. |
@peterhoeg git is used by openzwave build to find version-number from it's git-repo. So without it I got a warning that it doesn't exist. I don't think it matters very much for the actual usage though. Getting warnings like this:
|
Correct, you get the warning but $src is not a checked out git repo but simply a directory, so it cannot do anything there anyway. |
@peterhoeg I've rebased and squashed your changed. And I'll fixed some dependency issues for the CLI tools for the python library and have pushed it. I hope it looks good now :) |
Looks good. @dotlambda/@FRidh do you want this to go via staging? |
I manually checked that it won't create merge conflict, so I guess merging into master is fine. |
Thanks a lot @etu! |
Motivation for this change
OpenZWave can be used with a wide range of USB-Sticks used to controll Z-Wave devices.
Python_OpenZWave can be used with homeassistant that is already packaged to be able to control and script Z-Wave devices.
Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)