+Digest16 = NewType('Digest16', str)
+Digest32 = NewType('Digest32', str)
+
+
+class ChannelTableEntry(types.SimpleNamespace):
+ absolute_url: str
+ digest: Digest16
+ file: str
+ size: int
+ url: str
+
+
+class SearchPath(types.SimpleNamespace, ABC):
+ release_name: str
+
+ @abstractmethod
+ def pin(self, v: Verification, conf: configparser.SectionProxy) -> None:
+ pass
+
+
+class AliasSearchPath(SearchPath):
+ alias_of: str
+
+ def pin(self, v: Verification, conf: configparser.SectionProxy) -> None:
+ assert not hasattr(self, 'git_repo')
+
+
+class TarrableSearchPath(SearchPath):
+ channel_html: bytes
+ channel_url: str
+ forwarded_url: str
+ git_ref: str
+ git_repo: str
+ git_revision: str
+ old_git_revision: str
+ table: Dict[str, ChannelTableEntry]
+
+ def pin(self, v: Verification, conf: configparser.SectionProxy) -> None:
+ if hasattr(self, 'git_revision'):
+ self.old_git_revision = self.git_revision
+ del self.git_revision
+
+ if 'channel_url' in conf:
+ pin_channel(v, self)
+ conf['release_name'] = self.release_name
+ conf['tarball_url'] = self.table['nixexprs.tar.xz'].absolute_url
+ conf['tarball_sha256'] = self.table['nixexprs.tar.xz'].digest
+ else:
+ git_fetch(v, self)
+ conf['release_name'] = git_revision_name(v, self)
+ conf['git_revision'] = self.git_revision
+
+ def fetch(self, v: Verification, section: str,
+ conf: configparser.SectionProxy) -> str:
+ if 'git_repo' not in conf or 'release_name' not in conf:
+ raise Exception(
+ 'Cannot update unpinned channel "%s" (Run "pin" before "update")' %
+ section)
+
+ if 'channel_url' in conf:
+ return fetch_with_nix_prefetch_url(
+ v, conf['tarball_url'], Digest16(
+ conf['tarball_sha256']))
+
+ ensure_git_rev_available(v, self)
+ return git_get_tarball(v, self)
+
+
+class GitSearchPath(TarrableSearchPath):
+ pass
+
+
+class ChannelSearchPath(TarrableSearchPath):
+ pass
+
+