mirror of
https://github.com/Misterio77/Foundry.git
synced 2026-08-24 10:04:09 -05:00
electra: add cgit :)
This commit is contained in:
@@ -8,6 +8,7 @@ Here's my NixOS/home-manager config files. Requires [Nix flakes](https://nixos.w
|
||||
Looking for something simpler to start out with flakes? Try [my starter config repo](https://github.com/Misterio77/nix-starter-config).
|
||||
|
||||
**Highlights**:
|
||||
|
||||
- Multiple **NixOS configurations**, including **desktop**, **laptop**, **server**
|
||||
- **Opt-in persistence** through impermanence + blank snapshotting
|
||||
- **Encrypted** single **BTRFS** partition
|
||||
@@ -19,6 +20,7 @@ Looking for something simpler to start out with flakes? Try [my starter config r
|
||||
- **Declarative** **themes** and **wallpapers** with **nix-colors**
|
||||
|
||||
## Structure
|
||||
|
||||
- `flake.nix`: Entrypoint for hosts and home configurations. Also exposes a
|
||||
devshell for boostrapping (`nix develop` or `nix-shell`).
|
||||
- `lib`: A few lib functions for making my flake cleaner
|
||||
@@ -91,6 +93,7 @@ signing, as well as for SSH'ing around.
|
||||
## Tooling and applications I use
|
||||
|
||||
Most relevant user apps daily drivers:
|
||||
|
||||
- hyprland + swayidle + swaylock
|
||||
- waybar
|
||||
- neovim
|
||||
@@ -109,12 +112,14 @@ Most relevant user apps daily drivers:
|
||||
- sublime-music
|
||||
|
||||
Some of the services I host:
|
||||
|
||||
- navidrome
|
||||
- nextcloud
|
||||
- minecraft
|
||||
- headscale
|
||||
|
||||
Nixy stuff:
|
||||
|
||||
- nix-colors
|
||||
- sops-nix
|
||||
- impermanence
|
||||
|
||||
Generated
+3
-3
@@ -529,11 +529,11 @@
|
||||
"utils": "utils_5"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1661013705,
|
||||
"narHash": "sha256-rpbg9y7gvc9j26uDAerUAhrpCEEZplzzf+md2FmL3h0=",
|
||||
"lastModified": 1661058364,
|
||||
"narHash": "sha256-KRjLoxlrznRkbsJ3ciPg/uQG/+x0JcE60+W/RYXgcHU=",
|
||||
"owner": "~misterio",
|
||||
"repo": "website",
|
||||
"rev": "1674613d0086091703cb7b6261697aedb8c0f5a6",
|
||||
"rev": "bd2aa820d87579851ff0e613921c15c290df9a9b",
|
||||
"type": "sourcehut"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
td.linenos {
|
||||
width: 2em;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
{ pkgs, lib, persistence, ... }:
|
||||
let
|
||||
cgit = "${pkgs.semanticgit}";
|
||||
in
|
||||
{
|
||||
services = {
|
||||
nginx.virtualHosts = {
|
||||
"git.fontes.dev.br" = {
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
locations = {
|
||||
"=/cgit.css" = {
|
||||
alias = "${./cgit.css}";
|
||||
};
|
||||
"/assets" = {
|
||||
return = "301 https://fontes.dev.br$request_uri";
|
||||
};
|
||||
"/" = {
|
||||
root = "${cgit}/cgit";
|
||||
extraConfig = ''
|
||||
uwsgi_pass unix:/run/uwsgi/cgit.sock;
|
||||
include ${pkgs.nginx}/conf/uwsgi_params;
|
||||
uwsgi_modifier1 9;
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
uwsgi.instance.vassals.cgit = {
|
||||
type = "normal";
|
||||
master = "true";
|
||||
socket = "/run/uwsgi/cgit.sock";
|
||||
procname-master = "uwsgi cgit";
|
||||
plugins = [ "cgi" ];
|
||||
cgi = "${cgit}/cgit/cgit.cgi";
|
||||
};
|
||||
};
|
||||
systemd.services.create-cgit-cache = {
|
||||
description = "Create cache directory for cgit";
|
||||
enable = true;
|
||||
wantedBy = [ "uwsgi.service" ];
|
||||
serviceConfig = {
|
||||
type = "oneshot";
|
||||
};
|
||||
script = ''
|
||||
mkdir -p /run/cgit
|
||||
chown -R nginx:nginx /run/cgit
|
||||
'';
|
||||
};
|
||||
environment = {
|
||||
persistence = lib.mkIf persistence {
|
||||
"/persist".directories = [
|
||||
"/srv/git"
|
||||
];
|
||||
};
|
||||
etc."cgitrc".text = ''
|
||||
virtual-root=/
|
||||
|
||||
cache-size=1000
|
||||
cache-root=/run/cgit
|
||||
|
||||
root-title=Gabriel's Git
|
||||
root-desc=Source code for some of my projects
|
||||
logo-link=https://fontes.dev.br
|
||||
|
||||
enable-http-clone=1
|
||||
noplainemail=1
|
||||
|
||||
enable-git-config=1
|
||||
remove-suffix=1
|
||||
|
||||
css=/cgit.css
|
||||
head-include=${./head.html}
|
||||
nav-include=${./nav.html}
|
||||
|
||||
readme=:README.md
|
||||
readme=:README.rst
|
||||
|
||||
source-filter=${cgit}/lib/cgit/filters/syntax-highlighting.py
|
||||
about-filter=${cgit}/lib/cgit/filters/about-formatting.sh
|
||||
|
||||
scan-path=/srv/git/
|
||||
enable-git-config=1
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- From my main website -->
|
||||
<link href="/assets/style.css" rel="stylesheet">
|
||||
<link id="scheme-css" rel="stylesheet">
|
||||
<script src="/assets/main.js"></script>
|
||||
@@ -0,0 +1,14 @@
|
||||
<div class="title">{ <a href="/">Gabriel Fontes</a> }</div>
|
||||
|
||||
<ul>
|
||||
<li class="colorscheme">
|
||||
<a aria-label="Change color scheme" href="https://fontes.dev.br/colorscheme"></a>
|
||||
</li>
|
||||
<li><a href="https://fontes.dev.br/">about</a></li>
|
||||
<li><a href="https://fontes.dev.br/blog/">blog</a></li>
|
||||
<li><a href="https://fontes.dev.br/notes/">notes</a></li>
|
||||
<li><a href="https://fontes.dev.br/portfolio/">portfolio</a></li>
|
||||
<li><a aria-current="page" href="/">git</a></li>
|
||||
</ul>
|
||||
|
||||
<p><small>​</small></p>
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
imports = [
|
||||
./cgit
|
||||
./headscale.nix
|
||||
./mail.nix
|
||||
./nginx.nix
|
||||
|
||||
@@ -1,12 +1,25 @@
|
||||
{ pkgs, ... }:
|
||||
{ lib, ... }:
|
||||
{
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
recommendedTlsSettings = true;
|
||||
recommendedProxySettings = true;
|
||||
recommendedGzipSettings = true;
|
||||
recommendedOptimisation = true;
|
||||
clientMaxBodySize = "300m";
|
||||
services = {
|
||||
nginx = {
|
||||
enable = true;
|
||||
recommendedTlsSettings = true;
|
||||
recommendedProxySettings = true;
|
||||
recommendedGzipSettings = true;
|
||||
recommendedOptimisation = true;
|
||||
clientMaxBodySize = "300m";
|
||||
};
|
||||
|
||||
uwsgi = {
|
||||
enable = true;
|
||||
user = "nginx";
|
||||
group = "nginx";
|
||||
plugins = [ "cgi" ];
|
||||
instance = {
|
||||
type = "emperor";
|
||||
vassals = lib.mkBefore {};
|
||||
};
|
||||
};
|
||||
};
|
||||
networking.firewall.allowedTCPPorts = [ 80 443 ];
|
||||
}
|
||||
|
||||
@@ -8,47 +8,57 @@ let
|
||||
);
|
||||
in
|
||||
{
|
||||
services = let
|
||||
redir = {
|
||||
services =
|
||||
let
|
||||
redir = {
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
locations."/" = {
|
||||
return = "302 https://fontes.dev.br$request_uri";
|
||||
};
|
||||
};
|
||||
in {
|
||||
nginx.virtualHosts = {
|
||||
"misterio.me" = redir;
|
||||
"www.fontes.dev.br" = redir;
|
||||
"gabriel.fontes.dev.br" = redir;
|
||||
"fontes.dev.br" = {
|
||||
default = true;
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
locations."/" = {
|
||||
root = "${pkgs.website.main}/public";
|
||||
extraConfig = ''
|
||||
add_header Last-Modified "${toDateTime inputs.website.lastModified}";
|
||||
add_header Cache-Control max-age="${toString (60 * 60 * 24 /* One day */)}";
|
||||
'';
|
||||
in
|
||||
{
|
||||
nginx.virtualHosts = {
|
||||
"misterio.me" = redir;
|
||||
"www.fontes.dev.br" = redir;
|
||||
"gabriel.fontes.dev.br" = redir;
|
||||
"fontes.dev.br" = {
|
||||
default = true;
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
locations = {
|
||||
"/git" = {
|
||||
extraConfig = ''
|
||||
rewrite ^/git(.*)$ https://git.fontes.dev.br$1 last;
|
||||
'';
|
||||
};
|
||||
"/" = {
|
||||
root = "${pkgs.website.main}/public";
|
||||
extraConfig = ''
|
||||
add_header Last-Modified "${toDateTime inputs.website.lastModified}";
|
||||
add_header Cache-Control max-age="${toString (60 * 60 * 24 /* One day */)}";
|
||||
add_header Access-Control-Allow-Origin https://git.fontes.dev.br;
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
# Gemini
|
||||
agate = {
|
||||
enable = true;
|
||||
contentDir = pkgs.linkFarm "agate-website" [
|
||||
{
|
||||
name = "misterio.me";
|
||||
path = "${pkgs.website.main}/public";
|
||||
}
|
||||
{
|
||||
name = "fontes.dev.br";
|
||||
path = "${pkgs.website.main}/public";
|
||||
}
|
||||
];
|
||||
hostnames = [ "misterio.me" "fontes.dev.br" ];
|
||||
};
|
||||
};
|
||||
# Gemini
|
||||
agate = {
|
||||
enable = true;
|
||||
contentDir = pkgs.linkFarm "agate-website" [
|
||||
{
|
||||
name = "misterio.me";
|
||||
path = "${pkgs.website.main}/public";
|
||||
}
|
||||
{
|
||||
name = "fontes.dev.br";
|
||||
path = "${pkgs.website.main}/public";
|
||||
}
|
||||
];
|
||||
hostnames = [ "misterio.me" "fontes.dev.br" ];
|
||||
};
|
||||
};
|
||||
networking.firewall.allowedTCPPorts = [ 1965 ];
|
||||
}
|
||||
|
||||
@@ -64,6 +64,17 @@ let
|
||||
patches = (oldAttrs.patches or [ ]) ++ [ ./fix-xdpw-hyprland-crash.patch ];
|
||||
});
|
||||
|
||||
semanticgit = prev.cgit-pink.overrideAttrs (_oldAttrs: {
|
||||
pname = "semanticgit";
|
||||
version = "0.1";
|
||||
src = final.fetchFromSourcehut {
|
||||
owner = "~misterio";
|
||||
repo = "scgit";
|
||||
rev = "09512c00f0a791125fd768d978b793ddada3faef";
|
||||
sha256 = "sha256-MOyuKxGXQxZTp7QTlvEaGTkrCpTJY9AoW13KcmmOJxg=";
|
||||
};
|
||||
});
|
||||
|
||||
};
|
||||
in
|
||||
inputs.nixpkgs.lib.composeManyExtensions [ additions modifications ]
|
||||
|
||||
@@ -0,0 +1,205 @@
|
||||
diff --git a/ui-shared.c b/ui-shared.c
|
||||
index cdacf71..4f38930 100644
|
||||
--- a/ui-shared.c
|
||||
+++ b/ui-shared.c
|
||||
@@ -991,22 +991,22 @@ static void print_top_header(void)
|
||||
}
|
||||
if (logo && *logo) {
|
||||
html("<nav>");
|
||||
- if (ctx.cfg.nav_include) {
|
||||
- html_include(ctx.cfg.nav_include);
|
||||
- } else {
|
||||
- html("<a href='");
|
||||
- if (logo_link && *logo_link) {
|
||||
- html_attr(logo_link);
|
||||
- } else {
|
||||
- html_attr(cgit_rooturl());
|
||||
- }
|
||||
- html("'>");
|
||||
- html("<img src='");
|
||||
- html_attr(logo);
|
||||
- html("' alt='cgit logo'/>");
|
||||
- html("</a>");
|
||||
- }
|
||||
- html("</nav>\n");
|
||||
+ if (ctx.cfg.nav_include) {
|
||||
+ html_include(ctx.cfg.nav_include);
|
||||
+ } else {
|
||||
+ html("<a href='");
|
||||
+ if (logo_link && *logo_link) {
|
||||
+ html_attr(logo_link);
|
||||
+ } else {
|
||||
+ html_attr(cgit_rooturl());
|
||||
+ }
|
||||
+ html("'>");
|
||||
+ html("<img src='");
|
||||
+ html_attr(logo);
|
||||
+ html("' alt='cgit logo'/>");
|
||||
+ html("</a>");
|
||||
+ }
|
||||
+ html("</nav>\n");
|
||||
}
|
||||
html("</header>\n");
|
||||
}
|
||||
@@ -1016,9 +1016,9 @@ static void print_header(void)
|
||||
html("<header>\n");
|
||||
html("<h1>");
|
||||
if (ctx.repo) {
|
||||
- cgit_summary_link(ctx.repo->name, NULL, NULL, NULL);
|
||||
+ cgit_summary_link(ctx.repo->name, NULL, NULL, NULL);
|
||||
} else {
|
||||
- html_txt(ctx.cfg.root_title);
|
||||
+ html_txt(ctx.cfg.root_title);
|
||||
}
|
||||
html("</h1>\n");
|
||||
|
||||
@@ -1026,7 +1026,7 @@ static void print_header(void)
|
||||
if (ctx.repo) {
|
||||
html_txt(ctx.repo->desc);
|
||||
html("</p>");
|
||||
- html("<p>");
|
||||
+ html("<p>");
|
||||
if (ctx.repo->owner_filter) {
|
||||
cgit_open_filter(ctx.repo->owner_filter);
|
||||
html_txt(ctx.repo->owner);
|
||||
@@ -1041,18 +1041,18 @@ static void print_header(void)
|
||||
html("</p>\n");
|
||||
|
||||
if (ctx.repo && ctx.env.authenticated) {
|
||||
- html("<form>\n");
|
||||
- cgit_add_hidden_formfields(0, 1, ctx.qry.page);
|
||||
- html("<select name='h' onchange='this.form.submit();'>\n");
|
||||
- print_this_commit_option();
|
||||
- html("<optgroup label='branches'>");
|
||||
- for_each_branch_ref(print_branch_option, ctx.qry.head);
|
||||
- if (ctx.repo->enable_remote_branches)
|
||||
- for_each_remote_ref(print_branch_option, ctx.qry.head);
|
||||
- html("</optgroup>");
|
||||
- html("</select> ");
|
||||
- html("<input type='submit' value='switch'/>");
|
||||
- html("</form>");
|
||||
+ html("<form>\n");
|
||||
+ cgit_add_hidden_formfields(0, 1, ctx.qry.page);
|
||||
+ html("<select name='h' onchange='this.form.submit();'>\n");
|
||||
+ print_this_commit_option();
|
||||
+ html("<optgroup label='branches'>");
|
||||
+ for_each_branch_ref(print_branch_option, ctx.qry.head);
|
||||
+ if (ctx.repo->enable_remote_branches)
|
||||
+ for_each_remote_ref(print_branch_option, ctx.qry.head);
|
||||
+ html("</optgroup>");
|
||||
+ html("</select> ");
|
||||
+ html("<input type='submit' value='switch'/>");
|
||||
+ html("</form>");
|
||||
}
|
||||
html("</header>\n");
|
||||
}
|
||||
@@ -1065,8 +1065,32 @@ void cgit_print_pageheader(void)
|
||||
html("<main>");
|
||||
print_header();
|
||||
|
||||
- html("<table class='tabs'><tr><td>\n");
|
||||
if (ctx.env.authenticated && ctx.repo) {
|
||||
+ html("<nav>\n");
|
||||
+ html("<form class='right' method='get' action='");
|
||||
+ if (ctx.cfg.virtual_root) {
|
||||
+ char *fileurl = cgit_fileurl(ctx.qry.repo, "log",
|
||||
+ ctx.qry.vpath, NULL);
|
||||
+ html_url_path(fileurl);
|
||||
+ free(fileurl);
|
||||
+ }
|
||||
+ html("'>\n");
|
||||
+ cgit_add_hidden_formfields(1, 0, "log");
|
||||
+ html("<select name='qt'>\n");
|
||||
+ html_option("grep", "log msg", ctx.qry.grep);
|
||||
+ html_option("author", "author", ctx.qry.grep);
|
||||
+ html_option("committer", "committer", ctx.qry.grep);
|
||||
+ html_option("range", "range", ctx.qry.grep);
|
||||
+ html("</select>\n");
|
||||
+ html("<input class='txt' type='search' size='10' name='q' value='");
|
||||
+ html_attr(ctx.qry.search);
|
||||
+ html("'/>\n");
|
||||
+ html("<input type='submit' value='search'/>\n");
|
||||
+ html("</form>\n");
|
||||
+ html("</nav>\n");
|
||||
+
|
||||
+ html("<nav>\n");
|
||||
+ html("<ul>");
|
||||
if (ctx.repo->readme.nr) {
|
||||
reporevlink("about", "about", NULL,
|
||||
hc("about"), ctx.qry.head, NULL,
|
||||
@@ -1105,34 +1129,15 @@ void cgit_print_pageheader(void)
|
||||
html_attr(ctx.repo->homepage);
|
||||
html("'>homepage</a>");
|
||||
}
|
||||
- html("</td><td class='form'>");
|
||||
- html("<form class='right' method='get' action='");
|
||||
- if (ctx.cfg.virtual_root) {
|
||||
- char *fileurl = cgit_fileurl(ctx.qry.repo, "log",
|
||||
- ctx.qry.vpath, NULL);
|
||||
- html_url_path(fileurl);
|
||||
- free(fileurl);
|
||||
- }
|
||||
- html("'>\n");
|
||||
- cgit_add_hidden_formfields(1, 0, "log");
|
||||
- html("<select name='qt'>\n");
|
||||
- html_option("grep", "log msg", ctx.qry.grep);
|
||||
- html_option("author", "author", ctx.qry.grep);
|
||||
- html_option("committer", "committer", ctx.qry.grep);
|
||||
- html_option("range", "range", ctx.qry.grep);
|
||||
- html("</select>\n");
|
||||
- html("<input class='txt' type='search' size='10' name='q' value='");
|
||||
- html_attr(ctx.qry.search);
|
||||
- html("'/>\n");
|
||||
- html("<input type='submit' value='search'/>\n");
|
||||
- html("</form>\n");
|
||||
+ html("</ul>");
|
||||
+ html("</nav>\n");
|
||||
} else if (ctx.env.authenticated) {
|
||||
char *currenturl = cgit_currenturl();
|
||||
+ html("<nav>\n");
|
||||
site_link(NULL, "index", NULL, hc("repolist"), NULL, NULL, 0, 1);
|
||||
if (ctx.cfg.root_readme)
|
||||
site_link("about", "about", NULL, hc("about"),
|
||||
NULL, NULL, 0, 1);
|
||||
- html("</td><td class='form'>");
|
||||
html("<form method='get' action='");
|
||||
html_attr(currenturl);
|
||||
html("'>\n");
|
||||
@@ -1141,11 +1146,11 @@ void cgit_print_pageheader(void)
|
||||
html("'/>\n");
|
||||
html("<input type='submit' value='search'/>\n");
|
||||
html("</form>");
|
||||
+ html("</nav>\n");
|
||||
free(currenturl);
|
||||
}
|
||||
- html("</td></tr></table>\n");
|
||||
if (ctx.env.authenticated && ctx.repo && ctx.qry.vpath) {
|
||||
- html("<div class='path'>");
|
||||
+ html("<nav role='breadcrumbs'>");
|
||||
html("path: ");
|
||||
cgit_print_path_crumbs(ctx.qry.vpath);
|
||||
if (ctx.cfg.enable_follow_links && !strcmp(ctx.qry.page, "log")) {
|
||||
@@ -1156,7 +1161,7 @@ void cgit_print_pageheader(void)
|
||||
ctx.qry.follow = !ctx.qry.follow;
|
||||
html(")");
|
||||
}
|
||||
- html("</div>");
|
||||
+ html("</nav>");
|
||||
}
|
||||
html("<article>");
|
||||
}
|
||||
@@ -1187,10 +1192,10 @@ void cgit_compose_snapshot_prefix(struct strbuf *filename, const char *base,
|
||||
* i.e. each stripped tag can be inverted without ambiguities.
|
||||
*/
|
||||
if (get_oid(fmt("refs/tags/%s", ref), &oid) == 0 &&
|
||||
- (ref[0] == 'v' || ref[0] == 'V') && isdigit(ref[1]) &&
|
||||
- ((get_oid(fmt("refs/tags/%s", ref + 1), &oid) == 0) +
|
||||
- (get_oid(fmt("refs/tags/v%s", ref + 1), &oid) == 0) +
|
||||
- (get_oid(fmt("refs/tags/V%s", ref + 1), &oid) == 0) == 1))
|
||||
+ (ref[0] == 'v' || ref[0] == 'V') && isdigit(ref[1]) &&
|
||||
+ ((get_oid(fmt("refs/tags/%s", ref + 1), &oid) == 0) +
|
||||
+ (get_oid(fmt("refs/tags/v%s", ref + 1), &oid) == 0) +
|
||||
+ (get_oid(fmt("refs/tags/V%s", ref + 1), &oid) == 0) == 1))
|
||||
ref++;
|
||||
|
||||
strbuf_addf(filename, "%s-%s", base, ref);
|
||||
Reference in New Issue
Block a user