diff --git a/README.md b/README.md index 4be241732..c669288f9 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,8 @@ perform also an evaluation check, which must be passed for your repository. Comm `repos.json` but NOT `repos.json.lock` ``` -$ git add repo.json +$ git add repos.json +$ ./nur/format_repos_manifest # ensure repos.json is sorted alphabetically $ git commit -m "add repository" $ git push ``` diff --git a/ci/deploy.sh b/ci/deploy.sh index b150e6b1d..292fd935c 100755 --- a/ci/deploy.sh +++ b/ci/deploy.sh @@ -14,6 +14,14 @@ fi export encrypted_025d6e877aa4_key= encrypted_025d6e877aa4_iv= +./nur/format_repos_manifest +if [ -n "$(git diff --exit-code repos.json)" ]; then + echo "repos.json was not formatted before committing repos.json:" >&2 + git diff --exit-code repos.json + echo "Please run ./nur/format_repos_manifest and updates repos.json accordingly!" >&2 + exit 1 +fi + ./nur/update.py nix-build diff --git a/nur/format_repos_manifest b/nur/format_repos_manifest new file mode 100755 index 000000000..4db723555 --- /dev/null +++ b/nur/format_repos_manifest @@ -0,0 +1,21 @@ +#!/usr/bin/env nix-shell +#!nix-shell -p python3 -i python3 + +import json +import shutil +from pathlib import Path + +ROOT = Path(__file__).parent.parent + + +def main() -> None: + path = ROOT.joinpath("repos.json") + manifest = json.load(open(path)) + tmp_path = str(path) + ".tmp" + with open(tmp_path, "w+") as tmp: + json.dump(manifest, tmp, indent=4, sort_keys=True) + shutil.move(tmp_path, path) + + +if __name__ == "__main__": + main() diff --git a/nur/update.py b/nur/update.py index 273b65f32..ccd375fc1 100755 --- a/nur/update.py +++ b/nur/update.py @@ -148,7 +148,7 @@ def update_lock_file(repos: List[Repo]): tmp_file = str(LOCK_PATH) + "-new" with open(tmp_file, "w") as lock_file: - json.dump(dict(repos=locked_repos), lock_file, indent=4) + json.dump(dict(repos=locked_repos), lock_file, indent=4, sort_keys=True) shutil.move(tmp_file, LOCK_PATH) diff --git a/repos.json b/repos.json index 88fdd834e..f2dac38cb 100644 --- a/repos.json +++ b/repos.json @@ -1,13 +1,13 @@ { "repos": { - "dywedir":{ + "dywedir": { "url": "https://github.com/dywedir/nur-packages" }, - "mic92": { - "url": "https://github.com/Mic92/nur-packages" - }, "eeva": { "url": "https://framagit.org/eeva/nur-packages" + }, + "mic92": { + "url": "https://github.com/Mic92/nur-packages" } } -} +} \ No newline at end of file diff --git a/repos.json.lock b/repos.json.lock index 57fe4f651..a6c3f66d9 100644 --- a/repos.json.lock +++ b/repos.json.lock @@ -5,15 +5,15 @@ "sha256": "1kqvvprnvcnf6r482y9pyl0kd957kl129fx46v4vgvnql9a8rh19", "url": "https://github.com/dywedir/nur-packages" }, - "mic92": { - "rev": "f16345720229519cc9e72167c187806829fd8fc5", - "sha256": "0birygrcrivzdah0y0bshphrrwsrk0bbba2yz6d2yqms193vbb0k", - "url": "https://github.com/Mic92/nur-packages" - }, "eeva": { "rev": "1702147af6ec29a955b59c58da07a018c588e11d", "sha256": "013dzdc1zwqpcsnsgx9b7qzzkha1rhwaq6jvaf3dq19jkwgddxl2", "url": "https://framagit.org/eeva/nur-packages" + }, + "mic92": { + "rev": "f16345720229519cc9e72167c187806829fd8fc5", + "sha256": "0birygrcrivzdah0y0bshphrrwsrk0bbba2yz6d2yqms193vbb0k", + "url": "https://github.com/Mic92/nur-packages" } } } \ No newline at end of file