From 195977e87177c0c0ea1492be8c3f53a2749a4a10 Mon Sep 17 00:00:00 2001 From: rndusr Date: Fri, 19 Jan 2024 18:56:48 -0600 Subject: [PATCH] add cgit --- boxes/netbox/default.nix | 218 ++++++++++++++++++++++++++++++++------- flake.lock | 4 +- 2 files changed, 185 insertions(+), 37 deletions(-) diff --git a/boxes/netbox/default.nix b/boxes/netbox/default.nix index 0f5fcf2..ce56bad 100644 --- a/boxes/netbox/default.nix +++ b/boxes/netbox/default.nix @@ -1,6 +1,114 @@ { lib, config, pkgs, ... }: -{ +let + cgitrc = pkgs.writeText "cgitrc" '' + css=/static/cgit.css + logo=/static/logo.png + favicon=/static/favicon.ico + root-title=beepboop.systems + root-desc=quality git hosting + + readme=:README + readme=:readme + readme=:readme.txt + readme=:README.txt + readme=:readme.md + readme=:README.md + + remove-suffix=1 + section-from-path=1 + + section-sort=0 + + section=meta + + repo.url=about + repo.path=/doesnt/exist + repo.desc=about this site + + section=other services at beepboop.systems + + repo.url=bitwarden + repo.path=/doesnt/exist + repo.desc=a simple password manager + + repo.url=radicale + repo.path=/doesnt/exist + repo.desc=a simple calendar server + + repo.url=roundcube + repo.path=/doesnt/exist + repo.desc=mail.beepboop.systems webmail + + repo.url=gitea + repo.path=/doesnt/exist + repo.desc=real git hosting services (until this one is fully operational) + + section=projects + + repo.url=advent + repo.path=/var/lib/git/advent + repo.desc=advent of code solutions + + repo.url=desmos-computer + repo.path=/var/lib/git/desmos-computer + repo.desc=a minimal ISA implemented in the Desmos graphing calculator + + repo.url=dot_testing + repo.path=/var/lib/git/dot_testing + repo.desc=configuration files for NixOS/GNU+Linux boxes + + repo.url=esgd + repo.path=/var/lib/git/esgd + repo.desc=the exceedingly simple gopher daemon + + repo.url=mail-sync + repo.path=/var/lib/git/mail-sync + repo.desc=synchronize mail from walled gardens + + repo.url=mastosnake + repo.path=/var/lib/git/mastosnake + repo.desc=a low quality clone of Twitter Plays Snake + + repo.url=secmsg + repo.path=/var/lib/git/secmsg + repo.desc=a stupid (in)secure messaging client thing + + repo.url=ultimate + repo.path=/var/lib/git/ultimate + repo.desc=ultimate tic tac toe solving engine + + repo.url=wordlefish + repo.path=/var/lib/git/wordlefish + repo.desc=use information theory to solve wordle puzzles + + section=irc robots + + repo.url=botanybot + repo.path=/var/lib/git/botanybot + repo.desc=water bots on ~.club + + repo.url=coinminer + repo.path=/var/lib/git/coinminer + repo.desc=mine fake coins on irc + + repo.url=chaosbot + repo.path=/var/lib/git/chaosbot + repo.desc=robot to protect a user on chaos + + repo.url=modbot + repo.path=/var/lib/git/modbot + repo.desc=modular irc robot + + repo.url=pychaos + repo.path=/var/lib/git/pychaos + repo.desc=python chaos bot + + repo.url=universalducks + repo.path=/var/lib/git/universalducks + repo.desc=cross channel irc ducks + ''; +in { imports = [ ./hardware-configuration.nix @@ -25,6 +133,7 @@ dig htop gnumake + neovim ]; system.copySystemConfiguration = true; @@ -32,22 +141,19 @@ boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/vda"; -# services.cgit = { -# "beepboop.systems" = { -# extraConfig = '' -# root-desc="testing" -# -# section=main -# repo.url=dot_testing -# repo.path=/var/lib/git/dot_testing -# repo.desc=configuration for NixOS/Linux systems -# repo.owner=rndusr -# -# readme=:README.md -# ''; -# enable = true; -# }; -# }; + # cgit + users = { + groups.git = { }; + users.git = { + createHome = true; + home = /var/lib/git; + isSystemUser = true; + shell = "${pkgs.git}/bin/git-shell"; + group = "git"; + }; + }; + + services.fcgiwrap = { enable = true; user = "git"; group = "git"; }; networking.hostName = "netbox"; @@ -177,12 +283,54 @@ forceSSL = true; enableACME = true; root = "/var/www/beepboop.systems"; - }; - services.nginx.virtualHosts."webhooks.beepboop.systems" = { - forceSSL = true; - enableACME = true; - root = "/var/www/webhooks.beepboop.systems"; + locations."~* ^/static/(.+.(ico|css))$" = { + extraConfig = '' + alias ${pkgs.cgit}/cgit/$1; + ''; + }; + locations."/static/logo.png" = { + extraConfig = '' + try_files /icon.png /icon.png; + ''; + }; + locations."/about" = { + extraConfig = '' + try_files /about.html /about.html; + ''; + }; + locations."/bitwarden" = { + extraConfig = '' + return 301 https://bit.beepboop.systems; + ''; + }; + locations."/gitea" = { + extraConfig = '' + return 301 https://git.beepboop.systems/rndusr; + ''; + }; + locations."/radicale" = { + extraConfig = '' + return 301 https://cal.beepboop.systems; + ''; + }; + locations."/roundcube" = { + extraConfig = '' + return 301 https://mail.beepboop.systems; + ''; + }; + locations."/" = { + extraConfig = '' + include ${pkgs.nginx}/conf/fastcgi_params; + fastcgi_param CGIT_CONFIG ${cgitrc}; + fastcgi_param SCRIPT_FILENAME ${pkgs.cgit}/cgit/cgit.cgi; + fastcgi_split_path_info ^(/?)(.+)$; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param QUERY_STRING $args; + fastcgi_param HTTP_HOST $server_name; + fastcgi_pass unix:${config.services.fcgiwrap.socketAddress}; + ''; + }; }; services.nginx.virtualHosts."git.beepboop.systems" = { @@ -241,19 +389,19 @@ email = "nickforanick@protonmail.com"; }; -# services.roundcube = { -# enable = true; -# # this is the url of the vhost, not necessarily the same as the fqdn of -# # the mailserver -# hostName = "cube.beepboop.systems"; -# extraConfig = '' -# # starttls needed for authentication, so the fqdn required to match -# # the certificate -# $config['smtp_server'] = "tls://${config.mailserver.fqdn}"; -# $config['smtp_user'] = "%u"; -# $config['smtp_pass'] = "%p"; -# ''; -# }; + services.roundcube = { + enable = true; + # this is the url of the vhost, not necessarily the same as the fqdn of + # the mailserver + hostName = "cube.beepboop.systems"; + extraConfig = '' + # starttls needed for authentication, so the fqdn required to match + # the certificate + $config['smtp_server'] = "tls://${config.mailserver.fqdn}"; + $config['smtp_user'] = "%u"; + $config['smtp_pass'] = "%p"; + ''; + }; services.nginx.virtualHosts."roundcube.beepboop.systems" = { forceSSL = true; diff --git a/flake.lock b/flake.lock index eb830b4..a513034 100644 --- a/flake.lock +++ b/flake.lock @@ -210,11 +210,11 @@ "locked": { "lastModified": 1, "narHash": "sha256-wGl3ZnqjhpAEpTkzgjWxgsbmGX9c7TPCM4I0okuOYFE=", - "path": "/nix/store/z62lv62z8yn2vfgxk06aqdr7i6wmk2v0-source/builds", + "path": "/nix/store/2fjha7mwjnlsmd4s3y7a3lfk3lq3w87z-source/builds", "type": "path" }, "original": { - "path": "/nix/store/z62lv62z8yn2vfgxk06aqdr7i6wmk2v0-source/builds", + "path": "/nix/store/2fjha7mwjnlsmd4s3y7a3lfk3lq3w87z-source/builds", "type": "path" } },