Things
- new host `devbox`
- `flake-parts` module to manage agenix secrets
- Searx -> Google again 😩 (it was too slow)
- WIP `git-workspace` module for `home-manager`
- `cgit` module
- `spotify-adblocked` packaged
This commit is contained in:
parent
29bea282e7
commit
52298435cd
23 changed files with 947 additions and 67 deletions
86
modules/cgit/custom.css
Normal file
86
modules/cgit/custom.css
Normal file
|
@ -0,0 +1,86 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
@import url("cgit.css");
|
||||
|
||||
* { line-height: 1.25em; }
|
||||
|
||||
div#cgit {
|
||||
max-width: 117ch;
|
||||
margin: auto;
|
||||
font-family: monospace;
|
||||
-moz-tab-size: 4;
|
||||
tab-size: 4;
|
||||
}
|
||||
|
||||
div#cgit table#header td.sub {
|
||||
border-top: none;
|
||||
}
|
||||
div#cgit table#header td.sub.right {
|
||||
padding-right: 1em;
|
||||
}
|
||||
div#cgit table.tabs {
|
||||
border-bottom: none;
|
||||
}
|
||||
div#cgit div.content {
|
||||
border-bottom: none;
|
||||
}
|
||||
div#cgit table.list th a {
|
||||
color: inherit;
|
||||
}
|
||||
div#cgit table.list tr:nth-child(even) {
|
||||
background: inherit;
|
||||
}
|
||||
div#cgit table.list tr:hover {
|
||||
background: inherit;
|
||||
}
|
||||
div#cgit table.list tr.nohover-highlight:hover:nth-child(even) {
|
||||
background: inherit;
|
||||
}
|
||||
|
||||
div#cgit table.blob td.linenumbers a:target {
|
||||
color: goldenrod;
|
||||
text-decoration: underline;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
div#cgit div#summary {
|
||||
max-width: 80ch;
|
||||
}
|
||||
|
||||
/* for hilex(1) */
|
||||
div#cgit pre .Ke { color: dimgray; }
|
||||
div#cgit pre .Ma { color: green; }
|
||||
div#cgit pre .Co { color: navy; }
|
||||
div#cgit pre .St { color: teal; }
|
||||
div#cgit pre .Fo { color: teal; font-weight: bold; }
|
||||
div#cgit pre .Su { color: olive; }
|
||||
|
||||
/* for htagml(1) */
|
||||
div#cgit pre a.tag { color: inherit; text-decoration: underline; }
|
||||
div#cgit pre a.tag:target { color: goldenrod; outline: none; }
|
||||
|
||||
/* for mandoc(1) */
|
||||
table.head, table.foot { width: 100%; }
|
||||
td.head-rtitle, td.foot-os { text-align: right; }
|
||||
td.head-vol { text-align: center; }
|
||||
div.Pp { margin: 1ex 0ex; }
|
||||
div.Nd, div.Bf, div.Op { display: inline; }
|
||||
span.Pa, span.Ad { font-style: italic; }
|
||||
span.Ms { font-weight: bold; }
|
||||
dl.Bl-diag > dt { font-weight: bold; }
|
||||
code.Nm, code.Fl, code.Cm, code.Ic, code.In, code.Fd, code.Fn,
|
||||
code.Cd { font-weight: bold; font-family: inherit; }
|
||||
|
||||
h1.Sh { font-size: 1.5em; }
|
||||
table.Nm td:first-child { padding-right: 1ch; }
|
||||
code.Fl { white-space: nowrap; }
|
||||
span.RsT { font-style: italic; }
|
||||
dl.Bl-tag:not(.Bl-compact) > dt { margin-top: 1em; }
|
||||
ul.Bl-bullet:not(.Bl-compact) > li { margin-top: 1em; }
|
||||
div.Bd-indent { margin-left: 4ch; }
|
||||
table.Bl-column { width: 100%; }
|
||||
table.foot { margin-top: 1em; }
|
||||
|
||||
div#cgit a.permalink { color: inherit; }
|
133
modules/cgit/default.nix
Normal file
133
modules/cgit/default.nix
Normal file
|
@ -0,0 +1,133 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
globalConfig = config;
|
||||
settingsFormat = {
|
||||
type = with lib.types; let
|
||||
value =
|
||||
oneOf [int str]
|
||||
// {
|
||||
description = "INI-like atom (int or string)";
|
||||
};
|
||||
values =
|
||||
coercedTo value lib.singleton (listOf value)
|
||||
// {
|
||||
description = value.description + " or a list of them for duplicate keys";
|
||||
};
|
||||
in
|
||||
attrsOf values;
|
||||
generate = name: values:
|
||||
pkgs.writeText name (lib.generators.toKeyValue {listsAsDuplicateKeys = true;} values);
|
||||
};
|
||||
in {
|
||||
options.services.nginx.virtualHosts = mkOption {
|
||||
type = types.attrsOf (types.submodule ({config, ...}: let
|
||||
cfg = config.cgit;
|
||||
|
||||
# These are the global options for this submodule, but for nicer UX they
|
||||
# are inlined into the freeform settings. Hence they MUST NOT INTERSECT
|
||||
# with any settings from cgitrc!
|
||||
options = {
|
||||
enable = mkEnableOption "cgit";
|
||||
|
||||
location = mkOption {
|
||||
default = "/";
|
||||
type = types.str;
|
||||
description = ''
|
||||
Location to serve cgit on.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
# Remove the global options for serialization into cgitrc
|
||||
settings = removeAttrs cfg (attrNames options);
|
||||
in {
|
||||
options.cgit = mkOption {
|
||||
type = types.submodule {
|
||||
freeformType = settingsFormat.type;
|
||||
inherit options;
|
||||
config = {
|
||||
css = mkDefault "/cgit.css";
|
||||
logo = mkDefault "/cgit.png";
|
||||
favicon = mkDefault "/favicon.ico";
|
||||
};
|
||||
};
|
||||
default = {};
|
||||
example = literalExample ''
|
||||
{
|
||||
enable = true;
|
||||
virtual-root = "/";
|
||||
source-filter = "''${pkgs.cgit-pink}/lib/cgit/filters/syntax-highlighting.py";
|
||||
about-filter = "''${pkgs.cgit-pink}/lib/cgit/filters/about-formatting.sh";
|
||||
cache-size = 1000;
|
||||
scan-path = "/srv/git";
|
||||
include = [
|
||||
(builtins.toFile "cgitrc-extra-1" '''
|
||||
# Anything that has to be in a particular order
|
||||
''')
|
||||
(builtins.toFile "cgitrc-extra-2" '''
|
||||
# Anything that has to be in a particular order
|
||||
''')
|
||||
];
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Verbatim contents of the cgit runtime configuration file. Documentation
|
||||
(with cgitrc example file) is available in "man cgitrc". Or online:
|
||||
http://git.zx2c4.com/cgit/tree/cgitrc.5.txt
|
||||
'';
|
||||
};
|
||||
|
||||
config = let
|
||||
location = removeSuffix "/" cfg.location;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
locations."${location}/" = {
|
||||
root = "${pkgs.cgit-pink}/cgit/";
|
||||
tryFiles = "$uri @cgit";
|
||||
};
|
||||
locations."~ ^${location}/(cgit.(css|png)|favicon.ico|robots.txt)$" = {
|
||||
alias = "${pkgs.cgit-pink}/cgit/$1";
|
||||
};
|
||||
locations."~ ^${location}/custom.css$" = {
|
||||
alias = ./custom.css;
|
||||
};
|
||||
locations."@cgit" = {
|
||||
extraConfig =
|
||||
''
|
||||
include ${pkgs.nginx}/conf/fastcgi_params;
|
||||
fastcgi_param CGIT_CONFIG ${settingsFormat.generate "cgitrc" settings};
|
||||
fastcgi_param SCRIPT_FILENAME ${pkgs.cgit-pink}/cgit/cgit.cgi;
|
||||
fastcgi_param QUERY_STRING $args;
|
||||
fastcgi_param HTTP_HOST $server_name;
|
||||
fastcgi_pass unix:${globalConfig.services.fcgiwrap.socketAddress};
|
||||
''
|
||||
+ (
|
||||
if cfg.location == "/"
|
||||
then ''
|
||||
fastcgi_param PATH_INFO $uri;
|
||||
''
|
||||
else ''
|
||||
fastcgi_split_path_info ^(${location}/)(/?.+)$;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
''
|
||||
);
|
||||
};
|
||||
};
|
||||
}));
|
||||
};
|
||||
|
||||
config = let
|
||||
vhosts = config.services.nginx.virtualHosts;
|
||||
in
|
||||
mkIf (any (name: vhosts.${name}.cgit.enable) (attrNames vhosts)) {
|
||||
# make the cgitrc manpage available
|
||||
environment.systemPackages = [pkgs.cgit-pink];
|
||||
|
||||
services.fcgiwrap.enable = true;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue