swh.loader.package.nixguix.loader module#

swh.loader.package.nixguix.loader.EXTID_TYPE = 'subresource-integrity'#

The ExtID is an ASCII string, as defined by https://w3c.github.io/webappsec-subresource-integrity/

class swh.loader.package.nixguix.loader.NixGuixPackageInfo(url: str, filename: Optional[str], version: str, raw_info: Dict[str, Any], integrity: str, *, directory_extrinsic_metadata: List[RawExtrinsicMetadataCore] = [], checksums: Dict[str, str] = {})[source]#

Bases: BasePackageInfo

Method generated by attrs for class NixGuixPackageInfo.


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

classmethod from_metadata(metadata: Dict[str, Any], version: str) NixGuixPackageInfo[source]#
extid() Tuple[str, int, bytes][source]#

Returns a unique intrinsic identifier of this package info, or None if this package info is not ‘deduplicatable’ (meaning that we will always load it, instead of checking the ExtID storage to see if we already did)

class swh.loader.package.nixguix.loader.NixGuixLoader(storage: StorageInterface, url: str, unsupported_file_extensions: List[str] = [], **kwargs: Any)[source]#

Bases: PackageLoader[NixGuixPackageInfo]

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

Loader’s constructor. This raises exception if the minimal required

configuration is missing (cf. fn:check method).

  • storage – Storage instance

  • url – Origin url to load data from

visit_type: str = 'nixguix'#
integrity_by_url() Dict[str, str][source]#
get_versions() List[str][source]#

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


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


Returns metadata items, used by build_extrinsic_snapshot_metadata.

get_package_info(url) Iterator[Tuple[str, NixGuixPackageInfo]][source]#
Given a release version of a package, retrieve the associated

package information for such version.


version – Package version


(branch name, package metadata)

select_extid_target(p_info: NixGuixPackageInfo, extid_targets: Set[CoreSWHID]) Optional[CoreSWHID][source]#

Given a list of release extid targets, choses one appropriate for the given package info.

Package loaders shyould implement this if their ExtIDs may map to multiple releases, so they can fetch releases from the storage and inspect their fields to select the right one for this p_info.

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_release(p_info: NixGuixPackageInfo, uncompressed_path: str, directory: bytes) Optional[Release][source]#

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

  • p_info – Package information

  • uncompressed_path – Artifact uncompressed path on disk

origin: Origin#
loaded_snapshot_id: Optional[bytes]#
parent_origins: Optional[List[Origin]]#

If the given origin is a “forge fork” (ie. created with the “Fork” button of GitHub-like forges), build_extrinsic_origin_metadata() sets this to a list of origins it was forked from; closest parent first.

swh.loader.package.nixguix.loader.retrieve_sources(url: str) bytes[source]#

Retrieve sources. Potentially raise NotFound error.

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

  • ValueError if

  • - a required top level key is missing

  • - top-level version is not 1


source Dict cleaned up