swh.loader.package.nixguix.loader module

class swh.loader.package.nixguix.loader.NixGuixLoader(url)[source]

Bases: swh.loader.package.loader.PackageLoader

Load sources from a sources.json file. This loader is used to load sources used by functional package manager (eg. Nix and Guix).

visit_type = 'nixguix'

The first mirror of the mirror list is used as branch name in the snapshot.

Given a release version of a package, retrieve the associated

package information for such version.


version – Package version


(branch name, package metadata)

known_artifacts(snapshot: Optional[swh.model.model.Snapshot]) → Dict[bytes, swh.model.model.BaseModel][source]

Almost same implementation as the default one except it filters out the extra “evaluation” branch which does not have the right metadata structure.

resolve_revision_from(known_artifacts: Dict, artifact_metadata: Dict) → Optional[bytes][source]

Resolve the revision from a snapshot and an artifact metadata dict.

If the artifact has already been downloaded, this will return the existing revision targeting that uncompressed artifact directory. Otherwise, this returns None.

  • snapshot – Snapshot

  • artifact_metadata – Information dict


None or revision identifier

extra_branches() → Dict[bytes, Mapping[str, Any]][source]

We add a branch to the snapshot called ‘evaluation’ pointing to the revision used to generate the sources.json file. This revision is specified in the sources.json file itself. For the nixpkgs origin, this revision is coming from the github.com/nixos/nixpkgs repository.

Note this repository is not loaded explicitly. So, this pointer can target a nonexistent revision for a time. However, the github and gnu loaders are supposed to load this revision and should create the revision pointed by this branch.

This branch can be used to identify the snapshot associated to a Nix/Guix evaluation.

build_revision(a_metadata: Dict, uncompressed_path: str, directory: bytes) → Optional[swh.model.model.Revision][source]

Build the revision from the archive metadata (extrinsic artifact metadata) and the intrinsic metadata.

  • a_metadata – Artifact metadata

  • uncompressed_path – Artifact uncompressed path on disk


SWH data dict

swh.loader.package.nixguix.loader.retrieve_sources(url: str) → Dict[str, Any][source]
swh.loader.package.nixguix.loader.clean_sources(sources: Dict[str, Any]) → Dict[str, Any][source]

Validate and clean the sources structure. First, it ensures all top level keys are presents. Then, it walks on the sources list and removes sources that don’t contain required keys.


ValueError – if a top level key is missing