Add selfhosted services

This commit is contained in:
aloslider
2026-06-30 04:26:40 +03:00
parent f212c874b5
commit 13e407847f
78 changed files with 2346 additions and 690 deletions
@@ -0,0 +1,24 @@
{ config, lib, ... }:
with lib;
let
cfg = config.selfhosted;
domain = "${config.sops.placeholder."domains/serv"}";
zerobyteDomain = "${cfg.zerobyte.subdomain}.${domain}";
trustedOrigins = [
"https://${zerobyteDomain}"
"https://${cfg.pocket-id.subdomain}.${domain}"
];
in
{
sops.secrets = {
"zerobyte/app_secret" = { };
};
sops.templates."zerobyte.env".content = ''
TZ=${config.time.timeZone}
BASE_URL=https://${zerobyteDomain}
APP_SECRET=${config.sops.placeholder."zerobyte/app_secret"}
TRUST_PROXY=true
TRUSTED_ORIGINS=${(concatStringsSep "," trustedOrigins)}
'';
}
@@ -0,0 +1,61 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
common = config.selfhosted.common;
cfg = config.selfhosted.zerobyte;
hostDataPath = "${common.dataDir}/zerobyte";
in
{
imports = [ ./config.nix ];
options.selfhosted.zerobyte = {
name = mkOption {
type = types.str;
};
subdomain = mkOption {
type = types.str;
};
hostPort = mkOption {
type = types.port;
};
};
config = {
virtualisation.oci-containers.containers.${cfg.name} = {
image = "ghcr.io/nicotsx/zerobyte:latest";
environmentFiles = [ config.sops.templates."zerobyte.env".path ];
ports = [
"0.0.0.0:${toString cfg.hostPort}:4096"
];
volumes = [
"/etc/localtime:/etc/localtime:ro"
"${hostDataPath}/data:/var/lib/zerobyte"
"${hostDataPath}/backups:/mydata"
];
};
systemd.services."${common.backend}-${cfg.name}" = {
serviceConfig = {
Restart = lib.mkOverride 90 "always";
};
after = [
"${common.backend}-network-${common.network.name}.service"
"${common.backend}-${config.selfhosted.traefik.name}.service"
];
requires = [
"${common.backend}-network-${common.network.name}.service"
"${common.backend}-${config.selfhosted.traefik.name}.service"
];
partOf = [ "${common.backend}-${common.rootTarget.name}.target" ];
wantedBy = [ "${common.backend}-${common.rootTarget.name}.target" ];
preStart = ''
mkdir -p ${hostDataPath}/{data,backups}
'';
};
};
}