hosts/plover: reformat code

This commit is contained in:
Gabriel Arazas 2024-10-20 18:22:45 +08:00
parent a042399386
commit aa52173af2
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360
2 changed files with 40 additions and 32 deletions

View File

@ -10,14 +10,14 @@ let
codeForgeDomain = "code.${config.networking.domain}"; codeForgeDomain = "code.${config.networking.domain}";
giteaUser = config.users.users."${config.services.gitea.user}".name; giteaUser = config.users.users."${config.services.gitea.user}".name;
in in {
{
options.hosts.plover.services.gitea.enable = options.hosts.plover.services.gitea.enable =
lib.mkEnableOption "Gitea server for ${config.networking.domain}"; lib.mkEnableOption "Gitea server for ${config.networking.domain}";
config = lib.mkIf cfg.enable (lib.mkMerge [ config = lib.mkIf cfg.enable (lib.mkMerge [
{ {
sops.secrets = foodogsquaredLib.sops-nix.getSecrets ../../secrets/secrets.yaml { sops.secrets =
foodogsquaredLib.sops-nix.getSecrets ../../secrets/secrets.yaml {
"gitea/smtp_password".owner = giteaUser; "gitea/smtp_password".owner = giteaUser;
}; };
@ -60,7 +60,8 @@ in
"ui.meta" = { "ui.meta" = {
AUTHOR = "foodogsquared's code forge"; AUTHOR = "foodogsquared's code forge";
DESCRIPTION = "foodogsquared's personal projects and some archived and mirrored codebases."; DESCRIPTION =
"foodogsquared's personal projects and some archived and mirrored codebases.";
KEYWORDS = "foodogsquared,gitea,self-hosted"; KEYWORDS = "foodogsquared,gitea,self-hosted";
}; };
@ -77,7 +78,8 @@ in
ENABLED = true; ENABLED = true;
NEED_POSTPROCESS = true; NEED_POSTPROCESS = true;
FILE_EXTENSIONS = ".adoc,.asciidoc"; FILE_EXTENSIONS = ".adoc,.asciidoc";
RENDER_COMMAND = "${pkgs.asciidoctor}/bin/asciidoctor --embedded --out-file=- -"; RENDER_COMMAND =
"${pkgs.asciidoctor}/bin/asciidoctor --embedded --out-file=- -";
IS_INPUT_FILE = false; IS_INPUT_FILE = false;
}; };
@ -120,7 +122,9 @@ in
# Disk space is always assumed to be limited so we're really only limited # Disk space is always assumed to be limited so we're really only limited
# with 2 dumps. # with 2 dumps.
systemd.services.gitea-dump.preStart = lib.mkAfter '' systemd.services.gitea-dump.preStart = lib.mkAfter ''
${pkgs.findutils}/bin/find ${lib.escapeShellArg config.services.gitea.dump.backupDir} \ ${pkgs.findutils}/bin/find ${
lib.escapeShellArg config.services.gitea.dump.backupDir
} \
-maxdepth 1 -type f -iname '*.${config.services.gitea.dump.type}' -ctime 21 \ -maxdepth 1 -type f -iname '*.${config.services.gitea.dump.type}' -ctime 21 \
| tail -n -3 | xargs rm | tail -n -3 | xargs rm
''; '';
@ -128,20 +132,25 @@ in
# Customizing Gitea which you can see more details at # Customizing Gitea which you can see more details at
# https://docs.gitea.io/en-us/customizing-gitea/. We're just using # https://docs.gitea.io/en-us/customizing-gitea/. We're just using
# systemd-tmpfiles to make this work which is pretty convenient. # systemd-tmpfiles to make this work which is pretty convenient.
systemd.tmpfiles.rules = systemd.tmpfiles.rules = let
let
# To be used similarly to $GITEA_CUSTOM variable. # To be used similarly to $GITEA_CUSTOM variable.
giteaCustomDir = config.services.gitea.customDir; giteaCustomDir = config.services.gitea.customDir;
in in [
[ "L+ ${giteaCustomDir}/templates/home.tmpl - - - - ${
"L+ ${giteaCustomDir}/templates/home.tmpl - - - - ${../../files/gitea/home.tmpl}" ../../files/gitea/home.tmpl
"L+ ${giteaCustomDir}/public/img/logo.svg - - - - ${../../files/gitea/logo.svg}" }"
"L+ ${giteaCustomDir}/public/img/logo.png - - - - ${../../files/gitea/logo.png}" "L+ ${giteaCustomDir}/public/img/logo.svg - - - - ${
../../files/gitea/logo.svg
}"
"L+ ${giteaCustomDir}/public/img/logo.png - - - - ${
../../files/gitea/logo.png
}"
]; ];
} }
(lib.mkIf hostCfg.services.database.enable { (lib.mkIf hostCfg.services.database.enable {
sops.secrets = foodogsquaredLib.sops-nix.getSecrets ../../secrets/secrets.yaml { sops.secrets =
foodogsquaredLib.sops-nix.getSecrets ../../secrets/secrets.yaml {
"gitea/db_password".owner = giteaUser; "gitea/db_password".owner = giteaUser;
}; };
@ -182,9 +191,7 @@ in
enableACME = true; enableACME = true;
acmeRoot = null; acmeRoot = null;
kTLS = true; kTLS = true;
locations."/" = { locations."/" = { proxyPass = "http://gitea"; };
proxyPass = "http://gitea";
};
extraConfig = '' extraConfig = ''
proxy_cache ${config.services.nginx.proxyCachePath.apps.keysZoneName}; proxy_cache ${config.services.nginx.proxyCachePath.apps.keysZoneName};
''; '';
@ -195,7 +202,9 @@ in
zone services; zone services;
''; '';
servers = { servers = {
"localhost:${builtins.toString config.services.gitea.settings.server.HTTP_PORT}" = { }; "localhost:${
builtins.toString config.services.gitea.settings.server.HTTP_PORT
}" = { };
}; };
}; };
}) })
@ -207,7 +216,8 @@ in
gitea.settings = { gitea.settings = {
enabled = true; enabled = true;
backend = "systemd"; backend = "systemd";
filter = "gitea[journalmatch='_SYSTEMD_UNIT=gitea.service + _COMM=gitea']"; filter =
"gitea[journalmatch='_SYSTEMD_UNIT=gitea.service + _COMM=gitea']";
maxretry = 8; maxretry = 8;
}; };
}; };
@ -228,7 +238,8 @@ in
(lib.mkIf hostCfg.services.backup.enable { (lib.mkIf hostCfg.services.backup.enable {
# Add the following files to be backed up. # Add the following files to be backed up.
services.borgbackup.jobs.services-backup.paths = [ config.services.gitea.dump.backupDir ]; services.borgbackup.jobs.services-backup.paths =
[ config.services.gitea.dump.backupDir ];
}) })
]); ]);
} }

View File

@ -4,8 +4,7 @@
let let
hostCfg = config.hosts.plover; hostCfg = config.hosts.plover;
cfg = hostCfg.services.reverse-proxy; cfg = hostCfg.services.reverse-proxy;
in in {
{
options.hosts.plover.services.reverse-proxy.enable = options.hosts.plover.services.reverse-proxy.enable =
lib.mkEnableOption "preferred public-facing reverse proxy"; lib.mkEnableOption "preferred public-facing reverse proxy";
@ -60,9 +59,7 @@ in
extraConfig = '' extraConfig = ''
zone services 64k; zone services 64k;
''; '';
servers = { servers = { "localhost:80" = { }; };
"localhost:80" = { };
};
}; };
}; };