-
Notifications
You must be signed in to change notification settings - Fork 177
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
Some improvements to nix parsing #1403
Conversation
ad5b7f9
to
a91285e
Compare
You don't need This part is invalid, |
I don't think it is currently possible to get a link to the raw logs from the data that get published in the package.json as the raw log files all have hash or build ID in their URL, e.g. https://cache.nixos.org/log/s7ir5kdff5437fna8ks274sl537ks5md-firefox-devedition-unwrapped-126.0b5.drv or https://hydra.nixos.org/build/259278227/nixlog/1
Would something like UPSTREAM_DOWNLOAD_PAGE be okay for that link type?
Removing it. |
repology-schemacheck.py
Outdated
@@ -297,6 +297,9 @@ | |||
|
|||
# guix | |||
'download_hosts_blacklist': [str], | |||
|
|||
# nixos | |||
'branch': Coerce(str), |
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 prefer strict schema so just str.
repology/parsers/parsers/nix.py
Outdated
@@ -83,6 +100,11 @@ def extract_nix_licenses(whatever: Any) -> list[str]: | |||
|
|||
|
|||
class NixJsonParser(Parser): | |||
_branch: str | |||
|
|||
def __init__(self, branch: str = '') -> None: |
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.
We have str | None
for optional values.
repology/parsers/parsers/nix.py
Outdated
@@ -61,6 +61,23 @@ def extract_nix_licenses(whatever: Any) -> list[str]: | |||
return [] | |||
|
|||
|
|||
def nix_has_logs(meta: dict[str, Any], arch: str) -> bool: | |||
if 'platforms' not in meta or arch not in meta['platforms']: |
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.
Most X in meta and meta[X]
conditions can be simplified to meta.get(X, <default>)
.
repology/parsers/parsers/nix.py
Outdated
@@ -182,6 +204,31 @@ def iter_parse(self, path: str, factory: PackageFactory) -> Iterable[PackageMake | |||
if 'changelog' in meta: | |||
pkg.add_links(LinkType.UPSTREAM_CHANGELOG, meta.get('changelog')) | |||
|
|||
for arch in ['x86_64-linux', 'aarch64-linux', 'x86_64-darwin', 'aarch64-darwin']: |
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's strange to do loop over items of two kinds the differentiate them with extra condition. Let's do two loops (for linux and darwin) 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.
Or even better, let's do a constant map of (arch, platform, is_trunk) -> link templates
as in
_BUILD_LOGS_LINK_TEMPLATES = {
("x86_64", "linux", True): f'https://hydra.nixos.org/job/nixos/trunk-combined/nixpkgs.{key}.x86_64-linux',
...
}
for arch, platform in [('x86_64', 'linux')]:
if nix_has_logs(meta, f'{arch}-{platform}') and (template := _BUILD_LOGS_LINK_TEMPLATES.get(arch, platform, branch is not None)):
pkg.add_links(template.format(key = key, branch = branch))
which will also reduce code duplication.
repology/parsers/parsers/nix.py
Outdated
@@ -61,6 +61,23 @@ def extract_nix_licenses(whatever: Any) -> list[str]: | |||
return [] | |||
|
|||
|
|||
def nix_has_logs(meta: dict[str, Any], arch: str) -> bool: | |||
if 'platforms' not in meta or arch not in meta['platforms']: |
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'd also simplify this into single return with complex multiline condition.
repology/parsers/parsers/nix.py
Outdated
def nix_has_logs(meta: dict[str, Any], arch: str) -> bool: | ||
if 'platforms' not in meta or arch not in meta['platforms']: | ||
return False | ||
elif 'broken' in meta and meta['broken']: |
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.
Is it documented anywhere that packages with these flags are not built or that these flags indicate build failure? If latter is the case, isn't link still valid containing earlier (possibly successful) builds?
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.
There is some documentation at https://github.com/NixOS/nixpkgs/blob/master/doc/stdenv/meta.chapter.md, but it's sadly incomplete and missing a lot of stuff.
Most of these are pretty much we know it's broken, so no need to waste resources building.
repos.d/nixos.yaml
Outdated
@@ -21,6 +21,7 @@ | |||
url: https://channels.nixos.org/nixos-{{branch}}/packages.json.br | |||
parser: | |||
class: NixJsonParser | |||
branch: {{branch}} |
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.
Wrap in {% if branch %}
and quote for proper typing.
I've updated the the comment - let's add these links. I've requested a few changes.
It would be perfect. Note that you may want to add it to a few places where UPSTREAM_HOMEPAGE or UPSTREAM_DOWNLOADS are handled, namely in |
1f0df6d
to
7979f1b
Compare
Applied all recommend changes and add champion pr repology/repology-webapp#246 for the webapp. |
Excellent, thank you! |
Added build logs to nix, improved the parsing of URL fields in nix, and added binary names to nix.