hydra, cgit and vm-sala on mothership

This commit is contained in:
Andrea Ciceri 2023-04-11 23:45:52 +02:00
parent 58e7ae54f0
commit 026a0d0180
Signed by: aciceri
SSH key fingerprint: SHA256:/AagBweyV4Hlfg9u092n8hbHwD5fcB6A3qhDiDA65Rg
9 changed files with 489 additions and 0 deletions

57
modules/cgit/config.nix Normal file
View file

@ -0,0 +1,57 @@
{
lib,
pkgs,
...
}: let
repos-path = "/var/lib/cgit-repos";
cgit-setup-repos =
pkgs.writers.writePython3 "cgit-setup-repos" {
libraries = with pkgs.python3Packages; [PyGithub];
} ''
from github import Github
from pathlib import Path
c = Path("${repos-path}")
c.unlink(missing_ok=True)
with open(c, "w") as f:
for repo in Github().get_user("aciceri").get_repos():
f.writelines([
f"repo.url={repo.name}\n"
f"repo.path=/home/ccr/projects/aciceri/{repo.name}/.git\n"
f"repo.desc={repo.description}\n"
])
'';
in {
services.nginx.virtualHosts."git.aciceri.dev" = {
cgit = {
enable = true;
css = "/custom.css";
# scan-path = "/home/ccr/projects/aciceri";
virtual-root = "/";
cache-size = 1000;
include = [
(builtins.toString (pkgs.writeText "cgit-extra" ''
source-filter=${pkgs.cgit-pink}/lib/cgit/filters/syntax-highlighting.py
about-filter=${pkgs.cgit-pink}/lib/cgit/filters/about-formatting.sh
''))
repos-path
];
};
forceSSL = true;
enableACME = true;
# locations."/" = {
# proxyPass = "http://127.0.0.1:${builtins.toString config.services.hydra.port}";
# };
};
systemd.services.cgit-setup-repos = {
description = "Update GitHub personal repos for cgit";
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
};
wantedBy = ["multi-user.target"];
script = builtins.toString cgit-setup-repos;
};
}

View file

@ -24,6 +24,11 @@ with lib; let
pkgs.writeText name (lib.generators.toKeyValue {listsAsDuplicateKeys = true;} values);
};
in {
imports = [
../nginx-base
./config.nix
];
options.services.nginx.virtualHosts = mkOption {
type = types.attrsOf (types.submodule ({config, ...}: let
cfg = config.cgit;