From 4fa4c8d66983844739b9192bffba101bca026492 Mon Sep 17 00:00:00 2001 From: clerie Date: Sun, 25 May 2025 14:15:54 +0200 Subject: [PATCH 1/5] configuration/common: Don't force requests ca bundle environment var --- configuration/common/certificates.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/configuration/common/certificates.nix b/configuration/common/certificates.nix index ab443fe..c0c38b4 100644 --- a/configuration/common/certificates.nix +++ b/configuration/common/certificates.nix @@ -1,9 +1,11 @@ -{ config, ... }: +{ config, lib, ... }: + +with lib; { environment.sessionVariables = { - REQUESTS_CA_BUNDLE = config.security.pki.caBundle; + REQUESTS_CA_BUNDLE = mkDefault config.security.pki.caBundle; }; } From d334a1a73ca6cb2f817399100f4f8c2c307d2f8a Mon Sep 17 00:00:00 2001 From: clerie Date: Sun, 25 May 2025 19:59:59 +0200 Subject: [PATCH 2/5] pkgs/git-show-link: Link to files directly --- pkgs/git-show-link/git-show-link.py | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/pkgs/git-show-link/git-show-link.py b/pkgs/git-show-link/git-show-link.py index e7e78e6..d542d33 100755 --- a/pkgs/git-show-link/git-show-link.py +++ b/pkgs/git-show-link/git-show-link.py @@ -9,12 +9,16 @@ REMOTE_TYPES = { "github": { "match": re.compile(r'git@github.com:(?P[\w\.-]+)/(?P[\w\.-]+).git'), "format-branch": lambda g: f"https://github.com/{g.username}/{g.project}/tree/{g.branch}/", + "format-branch-file": lambda g: f"https://github.com/{g.username}/{g.project}/blob/{g.branch}/{g.path}", "format-commit": lambda g: f"https://github.com/{g.username}/{g.project}/commit/{g.commit}/", + "format-commit-file": lambda g: f"https://github.com/{g.username}/{g.project}/blob/{g.commit}/{g.path}", }, "gitea": { "match": re.compile(r'(?P[\w\.-]+)@(?P[\w\.-]+):(?P[\w\.-]+)/(?P[\w\.-]+).git'), "format-branch": lambda g: f"https://{g.host}/{g.username}/{g.project}/src/branch/{g.branch}/", + "format-branch-file": lambda g: f"https://{g.host}/{g.username}/{g.project}/src/branch/{g.branch}/{g.path}", "format-commit": lambda g: f"https://{g.host}/{g.username}/{g.project}/commit/{g.commit}/", + "format-commit-file": lambda g: f"https://{g.host}/{g.username}/{g.project}/src/commit/{g.commit}/{g.path}", }, } @@ -26,6 +30,7 @@ class FormatArgs: project: str = None commit: str = None branch: str = None + path: str = None def is_git_repo(): s = subprocess.run(["git", "rev-parse"], capture_output=True, text=True) @@ -70,6 +75,7 @@ def main(): prog='git-show-link', ) + parser.add_argument("path", nargs="?", default=None, help="Path to link to specific file or directory") parser.add_argument("--branch", dest="display_branch", action='store_true', help="Display link to branch, instead to commit") parser.add_argument("--remote-type", dest="remote_type", choices=REMOTE_TYPES.keys(), help="Specify remote type") @@ -102,14 +108,25 @@ def main(): remote_type_found = True g = FormatArgs(**m.groupdict()) + g.path = args.path - if args.display_branch: - g.branch = r["branch"] - print(remote_type["format-branch"](g)) + if args.path is not None: + if args.display_branch: + g.branch = r["branch"] + print(remote_type["format-branch-file"](g)) + else: + commit = get_last_commit() + g.commit = commit + print(remote_type["format-commit-file"](g)) else: - commit = get_last_commit() - g.commit = commit - print(remote_type["format-commit"](g)) + if args.display_branch: + g.branch = r["branch"] + print(remote_type["format-branch"](g)) + else: + commit = get_last_commit() + g.commit = commit + print(remote_type["format-commit"](g)) + break if not remote_type_found: From efad5a6cbb7e9419514d9c35983a917fd1575372 Mon Sep 17 00:00:00 2001 From: clerie Date: Sun, 25 May 2025 20:21:51 +0200 Subject: [PATCH 3/5] pkgs/git-show-link: Normalize paths --- pkgs/git-show-link/git-show-link.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/pkgs/git-show-link/git-show-link.py b/pkgs/git-show-link/git-show-link.py index d542d33..3ffaea3 100755 --- a/pkgs/git-show-link/git-show-link.py +++ b/pkgs/git-show-link/git-show-link.py @@ -4,6 +4,7 @@ import argparse from dataclasses import dataclass import re import subprocess +from pathlib import Path REMOTE_TYPES = { "github": { @@ -37,9 +38,17 @@ def is_git_repo(): return s.returncode == 0 +def get_git_dir(): + s = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output=True, text=True) + return Path(s.stdout.strip()) + def get_remote_branch(): s = subprocess.run(["git", "status", "--porcelain", "-uno", "-b", "--no-ahead-behind"], capture_output=True, text=True) + if s.stdout.startswith("## HEAD (no branch)"): + print("Detached head, can't link") + exit(1) + git_status_branch_info = s.stdout.splitlines()[0][3:].split()[0] branches = git_status_branch_info.split("...") @@ -86,6 +95,8 @@ def main(): exit(1) + git_dir_path = get_git_dir() + r = get_remote_branch() remote_url = get_remote_url(r["remote"]) @@ -108,7 +119,17 @@ def main(): remote_type_found = True g = FormatArgs(**m.groupdict()) - g.path = args.path + + if args.path is not None: + path = Path(args.path).absolute() + path = path.relative_to(git_dir_path) + + path = str(path) + + if path == ".": + path = "" + + g.path = path if args.path is not None: if args.display_branch: From cddd9b1a1e24f22c42c43b6101d43944574a2bcb Mon Sep 17 00:00:00 2001 From: clerie Date: Sun, 25 May 2025 20:48:07 +0200 Subject: [PATCH 4/5] pkgs/git-show-link: Improve linking to directory --- pkgs/git-show-link/git-show-link.py | 38 +++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/pkgs/git-show-link/git-show-link.py b/pkgs/git-show-link/git-show-link.py index 3ffaea3..ed4cad6 100755 --- a/pkgs/git-show-link/git-show-link.py +++ b/pkgs/git-show-link/git-show-link.py @@ -10,16 +10,20 @@ REMOTE_TYPES = { "github": { "match": re.compile(r'git@github.com:(?P[\w\.-]+)/(?P[\w\.-]+).git'), "format-branch": lambda g: f"https://github.com/{g.username}/{g.project}/tree/{g.branch}/", - "format-branch-file": lambda g: f"https://github.com/{g.username}/{g.project}/blob/{g.branch}/{g.path}", + "format-branch-file": lambda g: f"https://github.com/{g.username}/{g.project}/blob/{g.branch}/{g.file}", + "format-branch-dir": lambda g: f"https://github.com/{g.username}/{g.project}/tree/{g.branch}/{g.dir}", "format-commit": lambda g: f"https://github.com/{g.username}/{g.project}/commit/{g.commit}/", - "format-commit-file": lambda g: f"https://github.com/{g.username}/{g.project}/blob/{g.commit}/{g.path}", + "format-commit-file": lambda g: f"https://github.com/{g.username}/{g.project}/blob/{g.commit}/{g.file}", + "format-commit-dir": lambda g: f"https://github.com/{g.username}/{g.project}/tree/{g.commit}/{g.dir}", }, "gitea": { "match": re.compile(r'(?P[\w\.-]+)@(?P[\w\.-]+):(?P[\w\.-]+)/(?P[\w\.-]+).git'), "format-branch": lambda g: f"https://{g.host}/{g.username}/{g.project}/src/branch/{g.branch}/", - "format-branch-file": lambda g: f"https://{g.host}/{g.username}/{g.project}/src/branch/{g.branch}/{g.path}", + "format-branch-file": lambda g: f"https://{g.host}/{g.username}/{g.project}/src/branch/{g.branch}/{g.file}", + "format-branch-dir": lambda g: f"https://{g.host}/{g.username}/{g.project}/src/branch/{g.branch}/{g.dir}", "format-commit": lambda g: f"https://{g.host}/{g.username}/{g.project}/commit/{g.commit}/", - "format-commit-file": lambda g: f"https://{g.host}/{g.username}/{g.project}/src/commit/{g.commit}/{g.path}", + "format-commit-file": lambda g: f"https://{g.host}/{g.username}/{g.project}/src/commit/{g.commit}/{g.file}", + "format-commit-dir": lambda g: f"https://{g.host}/{g.username}/{g.project}/src/commit/{g.commit}/{g.dir}", }, } @@ -31,7 +35,8 @@ class FormatArgs: project: str = None commit: str = None branch: str = None - path: str = None + file: str = None + dir: str = None def is_git_repo(): s = subprocess.run(["git", "rev-parse"], capture_output=True, text=True) @@ -124,14 +129,19 @@ def main(): path = Path(args.path).absolute() path = path.relative_to(git_dir_path) - path = str(path) + if path.is_dir(): + path = str(path) - if path == ".": - path = "" + if path == ".": + path = "" + else: + path += "/" - g.path = path + g.dir = path + else: + g.file = str(path) - if args.path is not None: + if g.file is not None: if args.display_branch: g.branch = r["branch"] print(remote_type["format-branch-file"](g)) @@ -139,6 +149,14 @@ def main(): commit = get_last_commit() g.commit = commit print(remote_type["format-commit-file"](g)) + elif g.dir is not None: + if args.display_branch: + g.branch = r["branch"] + print(remote_type["format-branch-dir"](g)) + else: + commit = get_last_commit() + g.commit = commit + print(remote_type["format-commit-dir"](g)) else: if args.display_branch: g.branch = r["branch"] From 5ea30c7fd411429e5ac045b6aeca07a4d545405e Mon Sep 17 00:00:00 2001 From: Flake Update Bot Date: Mon, 26 May 2025 03:04:04 +0200 Subject: [PATCH 5/5] Update nixpkgs 2025-05-26-01-03 --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index fb4be50..463b1dc 100644 --- a/flake.lock +++ b/flake.lock @@ -551,11 +551,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1746328495, - "narHash": "sha256-uKCfuDs7ZM3QpCE/jnfubTg459CnKnJG/LwqEVEdEiw=", + "lastModified": 1748026106, + "narHash": "sha256-6m1Y3/4pVw1RWTsrkAK2VMYSzG4MMIj7sqUy7o8th1o=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "979daf34c8cacebcd917d540070b52a3c2b9b16e", + "rev": "063f43f2dbdef86376cc29ad646c45c46e93234c", "type": "github" }, "original": {