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
home-assistant: compute extraComponents from config #34494
Conversation
@@ -17,13 +17,16 @@ in { | |||
homeassistant = { | |||
name = "Home"; | |||
time_zone = "UTC"; | |||
latitude = "0.0"; | |||
longitude = "0.0"; |
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.
null island! :)
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 had to put something because this is a required part of the config. If you happen to know Atlantis' coordinates, I'd be happy to take them instead :)
"arduino" = ps: with ps; [ ]; | ||
"xiaomi_aqara" = ps: with ps; [ ]; | ||
"rpi_gpio" = ps: with ps; [ ]; | ||
"remember_the_milk" = ps: with ps; [ httplib2 ]; |
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.
Are these all normalized names? https://www.python.org/dev/peps/pep-0503/#normalized-names
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.
The names on the left are component names, no need to normalize them.
However, normalization is indeed important for finding the appropriate package. Is it the case that all pname
s inside Nixpkgs should be normalized?
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 wish we could use normalized pname
but we can't unfortunately because of https://github.com/pypa/warehouse/issues/2537
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.
Okay, then I don't have to normalize anything. Howver, a case-insensitive search seems to find some more packages. So, I use re.I
now.
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.
Attributes on the other hand should be normalized names.
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.
The attributes need to be called exactly as the components in order to generate a list of used components from the config. Otherwise I would have to write a function in Nix that normalizes names and then I'd have to recursively list all attribute paths of the config, normalize them and check if they appear in comonent-packages.nix
.
import re | ||
from pkg_resources import Requirement, RequirementParseError | ||
|
||
VERSION = '0.62.1' |
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.
parse this from the default.nix
?
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.
Done. However, I find the assertion to be rather ugly.
@@ -0,0 +1,75 @@ | |||
#! /usr/bin/env nix-shell | |||
#! nix-shell -i python3 -p "python3.withPackages (ps: with ps; [ setuptools ])" |
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 describe in the header how this script works? E.g., how does it determine the requirements? I see it tries to match requirements to the available Nix packages. Roughly describing in text what it does is useful.
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 added a description. Do you think it is clear enough?
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.
Looks good.
@@ -0,0 +1,428 @@ | |||
# Generated from parse-requirements.py |
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.
When should this file be regenerated? On every package update? You may want to note it in a comment in the default.nix
. Also, you could include in this file the version it was generated from. Then, when importing this file, you can assert its the same as the home-assistant version that is used in the derivation. Easy check.
8758bfd
to
2e3163f
Compare
2e3163f
to
78c2ca3
Compare
default = true; | ||
type = types.bool; | ||
description = '' | ||
If set to <literal>true</literal>, the components used in <literal>config</config> |
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.
Just fyi this line broke building manpages because of the incorrect closing of <literal>
.
Fixed in 7ebb82e
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.
Sorry. Thanks for fixing!
Motivation for this change
Home Assistant components usually have additional dependencies.
This PR includes a script that parses these dependencies into a Nix attribute set. Then, by specifying additional components or by looking at the config, these dependencies can automatically be added.
However, not all dependencies of all components are packaged yet nor will they ever be, probably.
Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)/cc @FRidh @peterhoeg @Mounium