created forgejo service

This commit is contained in:
Leyla Becker 2025-01-02 16:21:44 -06:00
parent fe1f2adf9f
commit 9ecba48dcf
2 changed files with 97 additions and 41 deletions

View file

@ -0,0 +1,36 @@
{
lib,
config,
...
}: let
forgejoPort = 8081;
in {
options.host.forgejo = {
enable = lib.mkEnableOption "should forgejo be enabled on this computer";
subdomain = lib.mkOption {
type = lib.types.str;
description = "subdomain of base domain that forgejo will be hosted at";
default = "forgejo";
};
};
config =
lib.mkIf config.host.forgejo.enable
{
enable = true;
database = {
type = "postgres";
socket = "/run/postgresql";
};
lfs.enable = true;
settings = {
server = {
DOMAIN = "${config.host.forgejo.subdomain}.${config.host.reverse_proxy.hostname}";
HTTP_PORT = forgejoPort;
};
};
host.reverse_proxy.subdomains.${config.host.jellyfin.subdomain} = {
target = "http://localhost:${toString forgejoPort}";
};
};
}

View file

@ -3,7 +3,9 @@
lib,
pkgs,
...
}: {
}: let
dataDir = "/var/lib/postgresql/15";
in {
options = {
host.postgres = {
enable = lib.mkEnableOption "enable postgres";
@ -40,7 +42,8 @@
};
};
config = lib.mkIf config.host.postgres.enable {
config = lib.mkIf config.host.postgres.enable (lib.mkMerge [
{
services = {
postgresql = {
enable = true;
@ -82,5 +85,22 @@
'';
};
};
}
(lib.mkIf config.host.impermanence.enable {
assertions = [
{
assertion = config.services.postgresql.dataDir == dataDir;
description = "postgres data directory does not match persistence";
}
];
environment.persistence."/persist/system/root" = {
enable = true;
hideMounts = true;
directories = [
dataDir
];
};
})
]);
}