Add selfhosted services
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
{ config, ... }:
|
||||
let
|
||||
cfg = config.selfhosted.homarr;
|
||||
poCfg = config.selfhosted.pocket-id;
|
||||
oidpDomain = "https://${poCfg.subdomain}.${config.sops.placeholder."domains/serv"}";
|
||||
in
|
||||
{
|
||||
sops.secrets = {
|
||||
"homarr/enc_key" = { };
|
||||
"homarr/client_id" = { };
|
||||
"homarr/client_secret" = { };
|
||||
"homarr/nextauth_secret" = { };
|
||||
};
|
||||
|
||||
sops.templates."homarr.env" = {
|
||||
content = ''
|
||||
SECRET_ENCRYPTION_KEY=${config.sops.placeholder."homarr/enc_key"}
|
||||
NEXTAUTH_SECRET=${config.sops.placeholder."homarr/nextauth_secret"}
|
||||
AUTH_PROVIDERS=oidc
|
||||
AUTH_OIDC_CLIENT_ID=${config.sops.placeholder."homarr/client_id"}
|
||||
AUTH_OIDC_CLIENT_SECRET=${config.sops.placeholder."homarr/client_secret"}
|
||||
AUTH_OIDC_ISSUER=${oidpDomain}
|
||||
AUTH_OIDC_CLIENT_NAME="Pocket ID"
|
||||
AUTH_OIDC_SCOPE_OVERWRITE=openid email profile groups
|
||||
AUTH_OIDC_GROUPS_ATTRIBUTE=groups
|
||||
AUTH_LOGOUT_REDIRECT_URL=${oidpDomain}
|
||||
AUTH_OIDC_AUTO_LOGIN=true
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
common = config.selfhosted.common;
|
||||
cfg = config.selfhosted.homarr;
|
||||
hostDataPath = "${common.dataDir}/homarr";
|
||||
in
|
||||
{
|
||||
imports = [ ./config.nix ];
|
||||
|
||||
options.selfhosted.homarr = {
|
||||
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/homarr-labs/homarr:latest";
|
||||
ports = [
|
||||
"0.0.0.0:${toString cfg.hostPort}:7575"
|
||||
];
|
||||
environmentFiles = [ config.sops.templates."homarr.env".path ];
|
||||
volumes = [
|
||||
"${hostDataPath}/data:/appdata"
|
||||
"/var/run/docker.sock:/var/run/docker.sock"
|
||||
];
|
||||
log-driver = "journald";
|
||||
extraOptions = [
|
||||
"--network=${common.network.name}"
|
||||
];
|
||||
};
|
||||
|
||||
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
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user