Small modules config restructure
Changed variables names in every module
This commit is contained in:
1 parent
c1d2e52bf8
commit
c92b90e406
83 files changed
+616
-523
No files matched your search
@@ -1,8 +1,9 @@
|
||||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
common = config.selfhosted.common;
|
||||
cfg = config.selfhosted.gitea;
|
||||
rootCfg = config.selfhosted;
|
||||
common = rootCfg.common;
|
||||
moduleCfg = rootCfg.gitea;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
@@ -11,22 +12,22 @@ in
|
||||
];
|
||||
|
||||
options.selfhosted.gitea = {
|
||||
enable = mkEnableOption "Enable ${cfg.targetName} root target";
|
||||
enable = mkEnableOption "Enable ${moduleCfg.targetName} root target";
|
||||
targetName = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
config = mkIf moduleCfg.enable {
|
||||
sops.secrets = {
|
||||
"gitea/db_password" = { };
|
||||
"gitea/client_id" = { };
|
||||
"gitea/client_secret" = { };
|
||||
};
|
||||
|
||||
systemd.targets."${common.backend}-${cfg.targetName}" = {
|
||||
systemd.targets."${common.backend}-${moduleCfg.targetName}" = {
|
||||
unitConfig = {
|
||||
Description = "Root target for ${cfg.targetName}";
|
||||
Description = "Root target for ${moduleCfg.targetName}";
|
||||
};
|
||||
wantedBy = [ "${common.backend}-${common.rootTarget.name}.target" ];
|
||||
partOf = [ "${common.backend}-${common.rootTarget.name}.target" ];
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
rootCfg = config.selfhosted.gitea;
|
||||
moduleCfg = config.selfhosted.gitea;
|
||||
in
|
||||
{
|
||||
config = mkIf rootCfg.enable {
|
||||
config = mkIf moduleCfg.enable {
|
||||
sops.templates."gitea-db.env".content = ''
|
||||
POSTGRES_DB=gitea
|
||||
POSTGRES_USER=gitea
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
common = config.selfhosted.common;
|
||||
rootCfg = config.selfhosted.gitea;
|
||||
cfg = rootCfg.postgresql;
|
||||
rootCfg = config.selfhosted;
|
||||
common = rootCfg.common;
|
||||
moduleCfg = rootCfg.gitea;
|
||||
cfg = moduleCfg.postgresql;
|
||||
hostDataPath = "${common.dataDir}/gitea";
|
||||
in
|
||||
{
|
||||
@@ -15,7 +16,7 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf rootCfg.enable {
|
||||
config = mkIf moduleCfg.enable {
|
||||
virtualisation.oci-containers.containers."${cfg.name}" = {
|
||||
image = "postgres:16";
|
||||
environmentFiles = [ config.sops.templates."gitea-db.env".path ];
|
||||
@@ -36,8 +37,8 @@ in
|
||||
serviceConfig = {
|
||||
Restart = lib.mkOverride 90 "always";
|
||||
};
|
||||
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
|
||||
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
|
||||
wantedBy = [ "${common.backend}-${moduleCfg.targetName}.target" ];
|
||||
partOf = [ "${common.backend}-${moduleCfg.targetName}.target" ];
|
||||
preStart = ''
|
||||
mkdir -p ${hostDataPath}/dbData
|
||||
chown 70:70 ${hostDataPath}/dbData
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
common = config.selfhosted.common;
|
||||
rootCfg = config.selfhosted.gitea;
|
||||
cfg = rootCfg.server;
|
||||
rootCfg = config.selfhosted;
|
||||
common = rootCfg.common;
|
||||
moduleCfg = rootCfg.gitea;
|
||||
cfg = moduleCfg.server;
|
||||
domain = "${config.sops.placeholder."domains/serv"}";
|
||||
giteaDomain = "${cfg.subdomain}.${domain}";
|
||||
in
|
||||
{
|
||||
config = mkIf rootCfg.enable {
|
||||
config = mkIf moduleCfg.enable {
|
||||
sops.templates."gitea.env".content = ''
|
||||
USER_UID=${common.user.uid}
|
||||
USER_GID=${common.group.gid}
|
||||
|
||||
GITEA__database__DB_TYPE=postgres
|
||||
GITEA__database__HOST=${rootCfg.postgresql.name}:5432
|
||||
GITEA__database__HOST=${moduleCfg.postgresql.name}:5432
|
||||
GITEA__database__NAME=gitea
|
||||
GITEA__database__USER=gitea
|
||||
GITEA__database__PASSWD=${config.sops.placeholder."gitea/db_password"}
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
common = config.selfhosted.common;
|
||||
rootCfg = config.selfhosted.gitea;
|
||||
cfg = rootCfg.server;
|
||||
rootCfg = config.selfhosted;
|
||||
common = rootCfg.common;
|
||||
moduleCfg = rootCfg.gitea;
|
||||
cfg = moduleCfg.server;
|
||||
hostDataPath = "${common.dataDir}/gitea";
|
||||
in
|
||||
{
|
||||
@@ -32,7 +33,7 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf rootCfg.enable {
|
||||
config = mkIf moduleCfg.enable {
|
||||
virtualisation.oci-containers.containers."${cfg.name}" = {
|
||||
image = "docker.io/gitea/gitea:28.2.0";
|
||||
ports = [
|
||||
@@ -53,10 +54,10 @@ in
|
||||
serviceConfig = {
|
||||
Restart = lib.mkOverride 90 "always";
|
||||
};
|
||||
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
|
||||
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
|
||||
requires = [ "${common.backend}-${rootCfg.postgresql.name}.service" ];
|
||||
after = [ "${common.backend}-${rootCfg.postgresql.name}.service" ];
|
||||
wantedBy = [ "${common.backend}-${moduleCfg.targetName}.target" ];
|
||||
partOf = [ "${common.backend}-${moduleCfg.targetName}.target" ];
|
||||
requires = [ "${common.backend}-${moduleCfg.postgresql.name}.service" ];
|
||||
after = [ "${common.backend}-${moduleCfg.postgresql.name}.service" ];
|
||||
preStart = ''
|
||||
mkdir -p ${hostDataPath}/data
|
||||
chown -R ${common.user.uid}:${common.group.gid} ${hostDataPath}/data
|
||||
@@ -98,7 +99,7 @@ in
|
||||
--provider "openidConnect" \
|
||||
--key "$CLIENT_ID" \
|
||||
--secret "$CLIENT_SECRET" \
|
||||
--auto-discover-url "https://${config.selfhosted.pocket-id.subdomain}.$DOMAIN/.well-known/openid-configuration" \
|
||||
--auto-discover-url "https://${rootCfg.pocket-id.subdomain}.$DOMAIN/.well-known/openid-configuration" \
|
||||
--scopes "openid email profile" \
|
||||
--skip-local-2fa
|
||||
|
||||
|
||||
Reference in new issue
Block a user