Skip to content
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

Merged
merged 1 commit into from Feb 3, 2018

Conversation

dotlambda
Copy link
Member

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
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

/cc @FRidh @peterhoeg @Mounium

@@ -17,13 +17,16 @@ in {
homeassistant = {
name = "Home";
time_zone = "UTC";
latitude = "0.0";
longitude = "0.0";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null island! :)

Copy link
Member Author

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 ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

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 pnames inside Nixpkgs should be normalized?

Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

@FRidh FRidh Feb 1, 2018

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.

Copy link
Member Author

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'
Copy link
Member

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?

Copy link
Member Author

@dotlambda dotlambda Feb 1, 2018

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 ])"
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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
Copy link
Member

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.

@dotlambda dotlambda force-pushed the home-assistant branch 2 times, most recently from 8758bfd to 2e3163f Compare February 1, 2018 23:30
@FRidh FRidh merged commit db58049 into NixOS:master Feb 3, 2018
default = true;
type = types.bool;
description = ''
If set to <literal>true</literal>, the components used in <literal>config</config>
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. Thanks for fixing!

@dotlambda dotlambda deleted the home-assistant branch February 3, 2018 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants