Skip to content
Snippets Groups Projects
Commit b4e1a5e8 authored by Tom Prince's avatar Tom Prince
Browse files

Update PaymentServer.

parent 40896010
No related branches found
No related tags found
2 merge requests!228merge develop into production,!195Update PaymentServer.
{ callPackage }: { callPackage, fetchFromGitHub, lib }:
let let
repo = callPackage ./repo.nix { }; repo-data = lib.importJSON ./repo.json;
repo = fetchFromGitHub (builtins.removeAttrs repo-data [ "branch" ]);
PaymentServer = (import "${repo}/nix").PaymentServer; PaymentServer = (import "${repo}/nix").PaymentServer;
in in
PaymentServer.components.exes."PaymentServer-exe" PaymentServer.components.exes."PaymentServer-exe"
{
"owner": "PrivateStorageio",
"repo": "PaymentServer",
"rev": "e080beb14ec58ffe8e55c35e6dddd46c5082887f",
"branch": "main",
"outputHashAlgo": "sha256",
"outputHash": "1zck9kawbs2lkr3qjipira9gawa4gxlqijqqjrmlvvyp9mr0fgxm"
}
{ fetchFromGitHub }:
fetchFromGitHub {
owner = "PrivateStorageio";
repo = "PaymentServer";
rev = "ff30e85c231a3b5ad76426bbf8801f8f76884367";
sha256 = "1spz19f5z96shmfpazj0rv6877xvchf3gl49a4xahjbbsz39x34x";
}
...@@ -16,6 +16,7 @@ let ...@@ -16,6 +16,7 @@ let
python-commands = [ python-commands = [
./update-nixpkgs ./update-nixpkgs
./update-gitlab-repo ./update-gitlab-repo
./update-github-repo
]; ];
in in
# This derivation creates a package that wraps our tools to setup an environment # This derivation creates a package that wraps our tools to setup an environment
......
#!/usr/bin/env python
"""
Update a pinned github repository.
Pass this path to a JSON file and it will update it to the latest
version of the branch it specifies. You can also pass a different
branch or repository owner, which will update the file to point at
the new branch/repository, and update to the latest version.
"""
import argparse
import json
from pathlib import Path
import httpx
from ps_tools import get_url_hash
HASH_TYPE = "sha512"
ARCHIVE_TEMPLATE = "https://api.github.com/repos/{owner}/{repo}/tarball/{rev}"
BRANCH_TEMPLATE = (
"https://api.github.com/repos/{owner}/{repo}/commits/{branch}"
)
def get_github_commit(config):
response = httpx.get(BRANCH_TEMPLATE.format(**config))
response.raise_for_status()
return response.json()["sha"]
def get_github_archive_url(config):
return ARCHIVE_TEMPLATE.format(**config)
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"repo_file",
metavar="repo-file",
type=Path,
help="JSON file with pinned configuration.",
)
parser.add_argument(
"--branch",
type=str,
help="Branch to update to.",
)
parser.add_argument(
"--owner",
type=str,
help="Repository owner to update to.",
)
parser.add_argument(
"--rev",
type=str,
help="Revision to pin.",
)
parser.add_argument(
"--dry-run",
action="store_true",
)
args = parser.parse_args()
repo_file = args.repo_file
config = json.loads(repo_file.read_text())
for key in ["owner", "branch"]:
if getattr(args, key) is not None:
config[key] = getattr(args, key)
if args.rev is not None:
config["rev"] = args.rev
else:
config["rev"] = get_github_commit(config)
archive_url = get_github_archive_url(config)
config.update(get_url_hash(HASH_TYPE, "source", archive_url))
output = json.dumps(config, indent=2)
if args.dry_run:
print(output)
else:
repo_file.write_text(output)
if __name__ == "__main__":
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment