2024-01-09 15:28:40 +00:00
|
|
|
# Nix configuration for the Reciproka Kolectivo Forgejo service
|
2021-10-07 02:13:48 +00:00
|
|
|
{
|
2022-08-15 07:32:25 +00:00
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
2023-04-29 11:31:49 +00:00
|
|
|
}: let
|
|
|
|
flake = builtins.getFlake (toString ../.);
|
|
|
|
nixpkgsUnstable = flake.inputs.nixpkgsUnstable;
|
|
|
|
in {
|
2023-12-19 14:32:26 +00:00
|
|
|
services.forgejo = {
|
2023-03-28 02:14:35 +00:00
|
|
|
enable = true; # Enable Forgejo
|
2024-01-09 15:28:40 +00:00
|
|
|
appName = "Reciproka Kolektivo: Forgejo Service"; # Give the site a name
|
2021-10-07 02:13:48 +00:00
|
|
|
database = {
|
2022-08-15 07:32:25 +00:00
|
|
|
type = "postgres"; # Database type
|
2023-04-29 11:31:49 +00:00
|
|
|
passwordFile = config.age.secrets.forgejo.path;
|
2021-10-07 02:13:48 +00:00
|
|
|
};
|
2023-12-04 09:06:30 +00:00
|
|
|
domain = "reciproka.dev"; # Domain name
|
|
|
|
httpPort = 3002; # Provided unique port
|
|
|
|
rootUrl = "https://reciproka.dev/"; # Root web URL
|
2021-10-07 02:13:48 +00:00
|
|
|
settings = let
|
2024-06-05 13:07:10 +00:00
|
|
|
DEFAULT.APP_NAME = "Reciproka Kolektivo: Forgejo Service"; # Give the site a name
|
2023-06-01 23:49:31 +00:00
|
|
|
server = {
|
|
|
|
DOMAIN = "reciproka.dev"; # Domain name
|
|
|
|
HTTP_PORT = 3002; # Provided unique port
|
|
|
|
ROOT_URL = "https://reciproka.dev/"; # Root web URL
|
|
|
|
};
|
2023-04-29 14:15:25 +00:00
|
|
|
service.DISABLE_REGISTRATION = true;
|
2021-10-07 02:13:48 +00:00
|
|
|
in {
|
|
|
|
mailer = {
|
|
|
|
ENABLED = true;
|
2023-05-09 13:04:57 +00:00
|
|
|
FROM = "fonto@reciproka.dev";
|
2021-10-07 02:13:48 +00:00
|
|
|
};
|
|
|
|
repository = {
|
|
|
|
DEFAULT_BRANCH = "consensus";
|
|
|
|
};
|
|
|
|
service = {
|
|
|
|
REGISTER_EMAIL_CONFIRM = true;
|
|
|
|
};
|
|
|
|
"markup.restructuredtext" = {
|
|
|
|
ENABLED = true;
|
|
|
|
FILE_EXTENSIONS = ".rst";
|
2023-12-20 13:56:11 +00:00
|
|
|
RENDER_COMMAND = "timeout 30s ${pkgs.pandoc}/bin/pandoc +RTS -M512M -RTS -f rst";
|
2021-10-07 02:13:48 +00:00
|
|
|
IS_INPUT_FILE = false;
|
|
|
|
};
|
|
|
|
ui = {
|
2023-03-28 02:14:35 +00:00
|
|
|
DEFAULT_THEME = "forgejo-auto"; # Set the default theme
|
2023-12-19 14:32:26 +00:00
|
|
|
THEMES = "forgejo-auto,forgejo-light,forgejo-dark,auto,arc-green,forgejo";
|
2021-10-07 02:13:48 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-08-16 02:54:29 +00:00
|
|
|
systemd = {
|
|
|
|
services = {
|
2023-12-19 14:32:26 +00:00
|
|
|
forgejo = {
|
|
|
|
# Ensure forgejo starts after keys are loaded
|
|
|
|
after = ["forgejo-dbpass-key.service"];
|
|
|
|
wants = ["forgejo-dbpass-key.service"];
|
2022-08-16 02:54:29 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-10-07 02:13:48 +00:00
|
|
|
services.postgresql = {
|
2022-08-15 07:32:25 +00:00
|
|
|
enable = true; # Ensure postgresql is enabled
|
2021-10-07 02:13:48 +00:00
|
|
|
authentication = ''
|
2023-12-19 14:32:26 +00:00
|
|
|
local forgejo all ident map=forgejo-users
|
2021-10-07 02:13:48 +00:00
|
|
|
'';
|
2022-08-15 07:32:25 +00:00
|
|
|
identMap =
|
2023-12-19 14:32:26 +00:00
|
|
|
# Map the forgejo user to postgresql
|
2021-10-07 02:13:48 +00:00
|
|
|
''
|
2023-12-19 14:32:26 +00:00
|
|
|
forgejo-users forgejo forgejo
|
2021-10-07 02:13:48 +00:00
|
|
|
'';
|
2023-12-19 14:32:26 +00:00
|
|
|
ensureDatabases = ["forgejo"]; # Ensure the database persists
|
2021-10-07 02:13:48 +00:00
|
|
|
ensureUsers = [
|
|
|
|
{
|
2023-12-19 14:32:26 +00:00
|
|
|
name = "forgejo"; # Ensure the database user persists
|
2024-06-05 12:14:54 +00:00
|
|
|
ensureDBOwnership = true;
|
2021-10-07 02:13:48 +00:00
|
|
|
}
|
|
|
|
];
|
2023-12-19 12:39:11 +00:00
|
|
|
package = pkgs.postgresql_16;
|
|
|
|
};
|
|
|
|
|
|
|
|
services.postgresqlBackup = {
|
|
|
|
enable = true;
|
|
|
|
compression = "zstd";
|
2023-12-19 14:32:26 +00:00
|
|
|
databases = ["forgejo"];
|
2023-12-19 12:39:11 +00:00
|
|
|
startAt = "*-*-* 15:00:00";
|
2021-10-07 02:13:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
services.nginx = {
|
2022-08-15 07:32:25 +00:00
|
|
|
enable = true; # Enable Nginx
|
2021-10-07 02:13:48 +00:00
|
|
|
recommendedGzipSettings = true;
|
|
|
|
recommendedOptimisation = true;
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
recommendedTlsSettings = true;
|
2022-08-15 07:32:25 +00:00
|
|
|
virtualHosts."source.jfdic.org" = {
|
2023-05-09 13:04:57 +00:00
|
|
|
enableACME = true; # Use ACME certs
|
|
|
|
forceSSL = true; # Force SSL
|
|
|
|
locations."/" = {
|
|
|
|
return = "301 https://reciproka.dev$request_uri";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
virtualHosts."reciproka.dev" = {
|
2023-03-28 02:14:35 +00:00
|
|
|
# Forgejo hostname
|
2022-08-15 07:32:25 +00:00
|
|
|
enableACME = true; # Use ACME certs
|
|
|
|
forceSSL = true; # Force SSL
|
2023-03-28 02:14:35 +00:00
|
|
|
locations."/".proxyPass = "http://localhost:3002/"; # Proxy Forgejo
|
2021-10-07 02:13:48 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
security.acme = {
|
|
|
|
acceptTerms = true;
|
|
|
|
certs = {
|
2023-05-09 13:04:57 +00:00
|
|
|
"reciproka.dev".email = "admin@reciproka.co";
|
|
|
|
"source.jfdic.org".email = "admin@reciproka.co";
|
2021-10-07 02:13:48 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|