swh.loader.package.nixguix.loader module

class swh.loader.package.nixguix.loader.NixGuixPackageInfo(url: str, filename: Optional[str], raw_info: Dict[str, Any], integrity: str, *, revision_extrinsic_metadata: List[swh.loader.package.loader.RawExtrinsicMetadataCore] = [])[source]

Bases: swh.loader.package.loader.BasePackageInfo

integrity

Hash of the archive, formatted as in the Subresource Integrity specification.

classmethod from_metadata(metadata: Dict[str, Any])swh.loader.package.nixguix.loader.NixGuixPackageInfo[source]
class swh.loader.package.nixguix.loader.NixGuixLoader(*args, **kwds)[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'
get_versions()[source]

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

get_metadata_authority()[source]

For package loaders that get extrinsic metadata, returns the authority the metadata are coming from.

get_extrinsic_snapshot_metadata()[source]

Returns metadata items, used by build_extrinsic_snapshot_metadata.

get_package_info(url) → Iterator[Tuple[str, swh.loader.package.nixguix.loader.NixGuixPackageInfo]][source]
Given a release version of a package, retrieve the associated

package information for such version.

Parameters

version – Package version

Returns

(branch name, package metadata)

known_artifacts(snapshot: Optional[swh.model.model.Snapshot]) → Dict[bytes, Optional[swh.model.collections.ImmutableDict[str, object]]][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, p_info: swh.loader.package.nixguix.loader.NixGuixPackageInfo) → 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.

Parameters
  • snapshot – Snapshot

  • p_info – Package information

Returns

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(p_info: swh.loader.package.nixguix.loader.NixGuixPackageInfo, 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.

Parameters
  • p_info – Package information

  • uncompressed_path – Artifact uncompressed path on disk

Returns

Revision object

swh.loader.package.nixguix.loader.retrieve_sources(url: str) → bytes[source]
swh.loader.package.nixguix.loader.parse_sources(raw_sources: bytes) → Dict[str, Any][source]
swh.loader.package.nixguix.loader.make_pattern_unsupported_file_extension(unsupported_file_extensions: List[str])[source]

Make a regexp pattern for unsupported file extension out of a list of unsupported archive extension list.

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

Validate and clean the sources structure. First, ensure all top level keys are present. Then, walk the sources list and remove sources that do not contain required keys.

Filter out source entries whose: - required keys are missing - source type is not supported - urls attribute type is not a list - extension is known not to be supported by the loader

Raises
  • ValueError if

  • - a required top level key is missing

  • - top-level version is not 1

Returns

source Dict cleaned up