From 43930cb8c22bc28ed64362845c5f4ebf54faabf2 Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Sat, 1 Aug 2026 21:43:25 -0400 Subject: added git with cgit --- nix/.sops.yaml | 7 + nix/README.md | 70 +++++- nix/flake.nix | 9 + nix/per-host/git/cgit-dark.css | 337 ++++++++++++++++++++++++++++ nix/per-host/git/configuration.nix | 141 ++++++++++++ nix/per-host/git/git-shell-commands/create | 49 ++++ nix/per-host/git/git-shell-commands/desc | 25 +++ nix/per-host/git/git-shell-commands/hide | 19 ++ nix/per-host/git/git-shell-commands/manage | 81 +++++++ nix/per-host/git/git-shell-commands/publish | 19 ++ nix/secrets/git.yaml | 25 +++ 11 files changed, 779 insertions(+), 3 deletions(-) create mode 100644 nix/per-host/git/cgit-dark.css create mode 100644 nix/per-host/git/configuration.nix create mode 100755 nix/per-host/git/git-shell-commands/create create mode 100755 nix/per-host/git/git-shell-commands/desc create mode 100755 nix/per-host/git/git-shell-commands/hide create mode 100755 nix/per-host/git/git-shell-commands/manage create mode 100755 nix/per-host/git/git-shell-commands/publish create mode 100644 nix/secrets/git.yaml diff --git a/nix/.sops.yaml b/nix/.sops.yaml index d03cddc..c28f7b1 100644 --- a/nix/.sops.yaml +++ b/nix/.sops.yaml @@ -2,6 +2,7 @@ keys: - &admin_me age12teny70e5cm3992z7atx9g9606d4a60dsl8nskzkpp234uelnctq82mqaa - &server_torrents_2 age1cunp9vshd45hlfqdxd4pdvg0qgfllk7mctff65s02wm447xgde7qar7z25 - &server_rproxy_2 age1h58rh5q0d7rg984g3e3qfrgwzu3ujzkkcg8f0ls5jlsvdy44f5ls3aywyx + - &server_git age152as4m0ytaq0dd78lhs7yla2twgkucun9ew02q5xhgffehgsmczqdl4trg creation_rules: - path_regex: 'secrets/torrents.*\.yaml$' @@ -15,3 +16,9 @@ creation_rules: - age: - *admin_me - *server_rproxy_2 + + - path_regex: 'secrets/git.*\.yaml$' + key_groups: + - age: + - *admin_me + - *server_git diff --git a/nix/README.md b/nix/README.md index 08d7305..a85e478 100644 --- a/nix/README.md +++ b/nix/README.md @@ -1,3 +1,7 @@ +# Deploy + +## Setup (one time) + Build base image: ```sh nixos-rebuild build-image --image-variant proxmox --flake .#base @@ -14,17 +18,77 @@ Convert to Proxmox Template. Run TF as usual using clone against the Template. +Generate host-keys, and age key for the host. ```sh # first time only ./generate-keys.sh torrents--2 +``` + +## Secrets w/ `sops` -# edit the .sops.yaml to include the host's age key +Edit the `.sops.yaml` to include the host's age key + +Create host's secrets: +```sh +sops secrets/torrents-2.yaml +``` -sops secrets/rproxy-2.yaml +## Push +```sh ./deploy.sh torrents-2 root ``` -Sources: +## References: + https://github.com/nix-community/nixos-generators https://gist.github.com/joshleecreates/e6892ca21b0e6b7c24d96ca2a24bf23e + +# Hosts + +## torrents-2 + +For all my Linux ISOs ofcourse. + +## rproxy-2 + +Entrypoint into my home-lab services. + +## git + +Set your `sshconfig`: +```sshconfig +# ~/.ssh/config +Host git.kumardamani.net + Port 2222 +``` + +> Non-SSH access (https) is always read-only, and anonymous. + +Manage repos with: +```sh +ssh -t git@git.kumardamani.net + +== git repo manager == + l) list repos + c) create repo + p) publish repo + h) hide repo + d) set description + x) delete repo + q) quit +> +``` + +Without the ssh config entry, use the abs path: +```sh +git clone ssh://git@git.kumardamani.net:2222/srv/git/.git +``` + +Move an existing local repo onto the server: +```sh +ssh git@git.kumardamani.net create +ssh git@git.kumardamani.net publish +git remote set-url origin git@git.kumardamani.net: +git push --all origin && git push --tags origin +``` diff --git a/nix/flake.nix b/nix/flake.nix index e4cde5f..ccc45ad 100644 --- a/nix/flake.nix +++ b/nix/flake.nix @@ -18,6 +18,15 @@ ]; }; + "git" = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./per-host/base/configuration.nix + ./per-host/git/configuration.nix + sops-nix.nixosModules.sops + ]; + }; + "torrents-2" = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ diff --git a/nix/per-host/git/cgit-dark.css b/nix/per-host/git/cgit-dark.css new file mode 100644 index 0000000..d3d5c8d --- /dev/null +++ b/nix/per-host/git/cgit-dark.css @@ -0,0 +1,337 @@ +/* + Color overrides for browsers running in dark mode. + Appended to the stock cgit 1.2.3 stylesheet. Taken verbatim from the + upstream cgit stylesheet as served on https://git.zx2c4.com/cgit.css + (the dark section was added to cgit upstream after the 1.2.3 release). + "only all and ..." forces very old browsers to ignore the media query: + https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries#improving_compatibility_with_older_browsers +*/ +:root { color-scheme: light dark; } +@media only all and (prefers-color-scheme: dark) { + html, div#cgit { color: #eee; background: #171717; } + div#cgit a { color: #3af; } + div#cgit .diffstat-header a { color: #28d; } + div#cgit table#header td.main a { color: #eee; } + div#cgit table#header td.sub { color: #999; } + div#cgit table.tabs { border-bottom-color: #444; } + div#cgit table.tabs td a { color: #888; } + div#cgit table.tabs td a.active { color: #fff; background-color: #444; } + div#cgit div.path { color: #eee; background-color: #333; } + div#cgit div.content { border-bottom-color: #bbb; } + div#cgit table.list tr { background: #171717; } + div#cgit table.list tr.logheader { background: #171717; } + div#cgit table.list tr:nth-child(even) { background: #171717; } + div#cgit table.list tr:nth-child(odd) { background: #1f1f1f; } + div#cgit table.list tr:hover { background: #333; } + div#cgit table.list tr.nohover { background: #171717; } + div#cgit table.list tr.nohover:hover { background: #171717; } + div#cgit table.list tr.nohover-highlight:hover:nth-child(even) { background: #171717; } + div#cgit table.list tr.nohover-highlight:hover:nth-child(odd) { background: #1f1f1f; } + div#cgit table.list td.commitgraph .column1 { color: #f55; } + div#cgit table.list td.commitgraph .column2 { color: #5f5; } + div#cgit table.list td.commitgraph .column3 { color: #ff5; } + div#cgit table.list td.commitgraph .column4 { color: #55f; } + div#cgit table.list td.commitgraph .column5 { color: #f5f; } + div#cgit table.list td.commitgraph .column6 { color: #5ff; } + div#cgit table.list td a { color: #eee; } + div#cgit table.list td a.ls-dir { color: #28d; } + div#cgit table.list td a:hover { color: #3af; } + div#cgit table#downloads { border-color: #888; } + div#cgit table#downloads th { background-color: #333; } + div#cgit div#blob { border-color: #eee; } + div#cgit table.blob { border-top-color: #eee; } + div#cgit table.blob td.hashes, + div#cgit table.blob td.lines { color: #eee; } + div#cgit table.blob td.linenumbers { border-right-color: gray; } + div#cgit table.blob td.linenumbers a, + div#cgit table.ssdiff td.lineno a { color: gray; } + div#cgit table.blob td.linenumbers a:hover, + div#cgit table.ssdiff td.lineno a:hover { color: #eee; } + div#cgit table.blame div.alt:nth-child(even) { background: #171717; } + div#cgit table.blame div.alt:nth-child(odd) { background: #1f1f1f; } + div#cgit table.bin-blob { border-color: #eee; } + div#cgit table.bin-blob th { border-color: #888; } + div#cgit table.bin-blob td { border-left-color: #888; } + div#cgit div.cgit-panel table { border-color: #555; background-color: #282828; } + div#cgit div.notes { border-color: #661; background-color: #220; } + div#cgit table.diffstat { border-color: #555; background-color: #282828; } + div#cgit table.diffstat td span.modechange { color: #c66; } + div#cgit table.diffstat td.add a { color: #6c6; } + div#cgit table.diffstat td.del a { color: #c66; } + div#cgit table.diffstat td.upd a { color: #3af; } + div#cgit table.diffstat td.graph td.add { background-color: #3a3; } + div#cgit table.diffstat td.graph td.rem { background-color: #a33; } + div#cgit div.diffstat-summary { color: #777; } + div#cgit table.diff td div.head { color: #eee; } + div#cgit table.diff td div.hunk { color: #28d; } + div#cgit table.diff td div.add { color: #6c6; } + div#cgit table.diff td div.del { color: #c66; } + div#cgit table.list td.reposection { color: #777; } + div#cgit ul.pager a { color: #888; } + div#cgit span.age-mins { color: #7f7; } + div#cgit span.age-hours { color: #7f7; } + div#cgit span.age-days { color: #9d9; } + div#cgit span.age-weeks { color: #bbb; } + div#cgit span.age-months { color: #888; } + div#cgit span.age-years { color: #666; } + div#cgit span.insertions { color: #7f7; } + div#cgit span.deletions { color: #e33; } + div#cgit div.footer { color: #555; } + div#cgit div.footer a { color: #555; } + div#cgit a.branch-deco { color: #fff; background-color: #361; border-color: #3b2; } + div#cgit a.tag-deco { color: #fff; background-color: #650; border-color: #ba3; } + div#cgit a.tag-annotated-deco { color: #fff; background-color: #840; border-color: #b96; } + div#cgit a.remote-deco { color: #fff; background-color: #348; border-color: #67c; } + div#cgit a.deco { color: #fff; background-color: #922; border-color: #d55; } + div#cgit a.branch-deco:hover, div#cgit table.list td a.branch-deco:hover, + div#cgit a.tag-deco:hover, div#cgit table.list td a.tag-deco:hover, + div#cgit a.tag-annotated-deco:hover, div#cgit table.list td a.tag-annotated-deco:hover, + div#cgit a.remote-deco:hover, div#cgit table.list td a.remote-deco:hover, + div#cgit a.deco:hover, div#cgit table.list td a.deco:hover { color: #fff; } + div#cgit table.stats { border-color: #555; } + div#cgit table.stats th { background-color: #333; border-color: #555; } + div#cgit table.stats td { border-color: #555; } + div#cgit table.stats td.sum { color: #5C7E9B; } + div#cgit table.vgraph { border-color: #eee; } + div#cgit table.vgraph th { background-color: #1f1f1f; border-color: black; } + div#cgit table.vgraph div.bar { background-color: #1f1f1f; } + div#cgit table.hgraph { border-color: #eee; } + div#cgit table.hgraph th { background-color: #1f1f1f; border-color: #eee; } + div#cgit table.hgraph div.bar { background-color: #1f1f1f; } + div#cgit table.ssdiff td { border-left-color: #555; border-right-color: #555; } + div#cgit table.ssdiff td.add { color: #eee; background: #353; } + div#cgit table.ssdiff td.add_dark { color: #eee; background: #030; } + div#cgit table.ssdiff span.add { background: #030; } + div#cgit table.ssdiff td.del { color: #eee; background: #533; } + div#cgit table.ssdiff td.del_dark { color: #eee; background: #411; } + div#cgit table.ssdiff span.del { background: #300; } + div#cgit table.ssdiff td.changed { color: #eee; background: #553; } + div#cgit table.ssdiff td.changed_dark { color: #eee; background: #330; } + div#cgit table.ssdiff td.lineno { color: #eee; background: #1f1f1f; } + div#cgit table.ssdiff td.hunk { color: #eee; background: #0D3D64; border-top-color: #555; border-bottom-color: #555; } + div#cgit table.ssdiff td.head { border-top-color: #555; border-bottom-color: #555; } + div#cgit table.ssdiff td.head div.head { color: #eee; } + div#cgit table.ssdiff td.foot { border-top-color: #555; } +} + +/* + Rendered-markdown fixes (about-filter's md2html injects its own + light-themed