WIP
This commit is contained in:
1 parent
13e407847f
commit
374428658a
80 files changed
+2517
-1058
No files matched your search
@@ -6,22 +6,23 @@ let
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./immich
|
||||
./ml
|
||||
./postgresql
|
||||
./redis
|
||||
./server
|
||||
];
|
||||
|
||||
options.selfhosted.immich = {
|
||||
enable = mkEnableOption "Enable ${cfg.targetName} root target";
|
||||
targetName = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
version = mkOption {
|
||||
subdomain = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
config = mkIf cfg.enable {
|
||||
sops.secrets = {
|
||||
"immich/db_password" = { };
|
||||
"immich/client_id" = { };
|
||||
@@ -33,6 +34,8 @@ in
|
||||
Description = "Root target for ${cfg.targetName}";
|
||||
};
|
||||
wantedBy = [ "${common.backend}-${common.rootTarget.name}.target" ];
|
||||
partOf = [ "${common.backend}-${common.rootTarget.name}.target" ];
|
||||
after = [ "${common.backend}-${common.rootTarget.name}.target" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{ config, ... }:
|
||||
{
|
||||
sops.templates."immich.env".content = ''
|
||||
DB_PASSWORD=${config.sops.placeholder."immich/db_password"}
|
||||
'';
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
common = config.selfhosted.common;
|
||||
cfg = config.selfhosted.immich;
|
||||
cfgPath = "/config/immich.json";
|
||||
hostDataPath = "${common.dataDir}/immich";
|
||||
in
|
||||
{
|
||||
imports = [ ./config.nix ];
|
||||
|
||||
options.selfhosted.immich.immich = {
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
subdomain = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
hostPort = mkOption {
|
||||
type = types.port;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
virtualisation.oci-containers.containers."${cfg.immich.name}" = {
|
||||
image = "ghcr.io/immich-app/immich-server:${cfg.version}";
|
||||
ports = [
|
||||
"0.0.0.0:${toString cfg.immich.hostPort}:2283"
|
||||
];
|
||||
environmentFiles = [ config.sops.templates."immich.env".path ];
|
||||
environment = {
|
||||
IMMICH_VERSION = cfg.version;
|
||||
DB_HOSTNAME = cfg.postgresql.name;
|
||||
DB_DATABASE_NAME = cfg.postgresql.db;
|
||||
DB_USERNAME = cfg.postgresql.user;
|
||||
REDIS_HOSTNAME = cfg.redis.name;
|
||||
};
|
||||
volumes = [
|
||||
"${hostDataPath}/data:/data"
|
||||
"/etc/localtime:/etc/localtime:ro"
|
||||
];
|
||||
log-driver = "journald";
|
||||
extraOptions = [
|
||||
"--network=${common.network.name}"
|
||||
];
|
||||
};
|
||||
|
||||
systemd.services."${common.backend}-${cfg.immich.name}" = {
|
||||
serviceConfig = {
|
||||
Restart = lib.mkOverride 90 "always";
|
||||
};
|
||||
after = [
|
||||
"${common.backend}-network-${common.network.name}.service"
|
||||
"${common.backend}-${cfg.postgresql.name}.service"
|
||||
"${common.backend}-${cfg.redis.name}.service"
|
||||
"${common.backend}-${config.selfhosted.traefik.name}.service"
|
||||
];
|
||||
requires = [
|
||||
"${common.backend}-network-${common.network.name}.service"
|
||||
"${common.backend}-${cfg.postgresql.name}.service"
|
||||
"${common.backend}-${cfg.redis.name}.service"
|
||||
"${common.backend}-${config.selfhosted.traefik.name}.service"
|
||||
];
|
||||
partOf = [ "${common.backend}-${cfg.targetName}.target" ];
|
||||
wantedBy = [ "${common.backend}-${cfg.targetName}.target" ];
|
||||
preStart = ''
|
||||
mkdir -p ${hostDataPath}/data
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,6 +1,12 @@
|
||||
{ config, ... }:
|
||||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
rootCfg = config.selfhosted.immich;
|
||||
in
|
||||
{
|
||||
sops.templates."immich-db.env".content = ''
|
||||
POSTGRES_PASSWORD=${config.sops.placeholder."immich/db_password"}
|
||||
'';
|
||||
config = mkIf rootCfg.enable {
|
||||
sops.templates."immich-db.env".content = ''
|
||||
POSTGRES_PASSWORD=${config.sops.placeholder."immich/db_password"}
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -2,8 +2,10 @@
|
||||
with lib;
|
||||
let
|
||||
common = config.selfhosted.common;
|
||||
cfg = config.selfhosted.immich;
|
||||
rootCfg = config.selfhosted.immich;
|
||||
cfg = rootCfg.ml;
|
||||
hostDataPath = "${common.dataDir}/immich";
|
||||
version = "v3.1.0";
|
||||
in
|
||||
{
|
||||
options.selfhosted.immich.ml = {
|
||||
@@ -12,11 +14,11 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
virtualisation.oci-containers.containers."${cfg.ml.name}" = {
|
||||
image = "ghcr.io/immich-app/immich-machine-learning:${cfg.version}";
|
||||
config = mkIf rootCfg.enable {
|
||||
virtualisation.oci-containers.containers."${cfg.name}" = {
|
||||
image = "ghcr.io/immich-app/immich-machine-learning:${version}";
|
||||
environment = {
|
||||
IMMICH_VERSION = cfg.version;
|
||||
IMMICH_VERSION = version;
|
||||
};
|
||||
volumes = [
|
||||
"${hostDataPath}/cache:/cache"
|
||||
@@ -26,14 +28,14 @@ in
|
||||
];
|
||||
};
|
||||
|
||||
systemd.services."${common.backend}-${cfg.ml.name}" = {
|
||||
systemd.services."${common.backend}-${cfg.name}" = {
|
||||
serviceConfig = {
|
||||
Restart = lib.mkOverride 90 "always";
|
||||
};
|
||||
after = [ "${common.backend}-network-${common.network.name}.service" ];
|
||||
requires = [ "${common.backend}-network-${common.network.name}.service" ];
|
||||
partOf = [ "${common.backend}-${cfg.targetName}.target" ];
|
||||
wantedBy = [ "${common.backend}-${cfg.targetName}.target" ];
|
||||
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
|
||||
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
|
||||
requires = [ "${common.backend}-${rootCfg.server.name}.service" ];
|
||||
after = [ "${common.backend}-${rootCfg.server.name}.service" ];
|
||||
preStart = ''
|
||||
mkdir -p ${hostDataPath}/cache
|
||||
'';
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
{ config, ... }:
|
||||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
rootCfg = config.selfhosted.immich;
|
||||
in
|
||||
{
|
||||
sops.templates."immich-db.env".content = ''
|
||||
POSTGRES_PASSWORD=${config.sops.placeholder."immich/db_password"}
|
||||
'';
|
||||
config = mkIf rootCfg.enable {
|
||||
sops.templates."immich-db.env".content = ''
|
||||
POSTGRES_PASSWORD=${config.sops.placeholder."immich/db_password"}
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -2,7 +2,8 @@
|
||||
with lib;
|
||||
let
|
||||
common = config.selfhosted.common;
|
||||
cfg = config.selfhosted.immich;
|
||||
rootCfg = config.selfhosted.immich;
|
||||
cfg = rootCfg.postgresql;
|
||||
hostDataPath = "${common.dataDir}/immich";
|
||||
in
|
||||
{
|
||||
@@ -20,13 +21,13 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
virtualisation.oci-containers.containers."${cfg.postgresql.name}" = {
|
||||
config = mkIf rootCfg.enable {
|
||||
virtualisation.oci-containers.containers."${cfg.name}" = {
|
||||
image = "ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0@sha256:bcf63357191b76a916ae5eb93464d65c07511da41e3bf7a8416db519b40b1c23";
|
||||
environmentFiles = [ config.sops.templates."immich-db.env".path ];
|
||||
environment = {
|
||||
POSTGRES_DB = cfg.postgresql.db;
|
||||
POSTGRES_USER = cfg.postgresql.user;
|
||||
POSTGRES_DB = cfg.db;
|
||||
POSTGRES_USER = cfg.user;
|
||||
POSTGRES_INITDB_ARGS = "--data-checksums";
|
||||
};
|
||||
volumes = [
|
||||
@@ -39,14 +40,12 @@ in
|
||||
];
|
||||
};
|
||||
|
||||
systemd.services."${common.backend}-${cfg.postgresql.name}" = {
|
||||
systemd.services."${common.backend}-${cfg.name}" = {
|
||||
serviceConfig = {
|
||||
Restart = lib.mkOverride 90 "always";
|
||||
};
|
||||
after = [ "${common.backend}-network-${common.network.name}.service" ];
|
||||
requires = [ "${common.backend}-network-${common.network.name}.service" ];
|
||||
partOf = [ "${common.backend}-${cfg.targetName}.target" ];
|
||||
wantedBy = [ "${common.backend}-${cfg.targetName}.target" ];
|
||||
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
|
||||
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
|
||||
preStart = ''
|
||||
mkdir -p ${hostDataPath}/db
|
||||
'';
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
with lib;
|
||||
let
|
||||
common = config.selfhosted.common;
|
||||
cfg = config.selfhosted.immich;
|
||||
rootCfg = config.selfhosted.immich;
|
||||
cfg = rootCfg.redis;
|
||||
in
|
||||
{
|
||||
options.selfhosted.immich.redis = {
|
||||
@@ -11,8 +12,8 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
virtualisation.oci-containers.containers."${cfg.redis.name}" = {
|
||||
config = mkIf rootCfg.enable {
|
||||
virtualisation.oci-containers.containers."${cfg.name}" = {
|
||||
image = "docker.io/valkey/valkey:9@sha256:4963247afc4cd33c7d3b2d2816b9f7f8eeebab148d29056c2ca4d7cbc966f2d9";
|
||||
log-driver = "journald";
|
||||
extraOptions = [
|
||||
@@ -21,14 +22,12 @@ in
|
||||
];
|
||||
};
|
||||
|
||||
systemd.services."${common.backend}-${cfg.redis.name}" = {
|
||||
systemd.services."${common.backend}-${cfg.name}" = {
|
||||
serviceConfig = {
|
||||
Restart = lib.mkOverride 90 "always";
|
||||
};
|
||||
after = [ "${common.backend}-network-${common.network.name}.service" ];
|
||||
requires = [ "${common.backend}-network-${common.network.name}.service" ];
|
||||
partOf = [ "${common.backend}-${cfg.targetName}.target" ];
|
||||
wantedBy = [ "${common.backend}-${cfg.targetName}.target" ];
|
||||
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
|
||||
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
rootCfg = config.selfhosted.immich;
|
||||
in
|
||||
{
|
||||
config = mkIf rootCfg.enable {
|
||||
sops.templates."immich.env".content = ''
|
||||
DB_PASSWORD=${config.sops.placeholder."immich/db_password"}
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
common = config.selfhosted.common;
|
||||
rootCfg = config.selfhosted.immich;
|
||||
cfg = rootCfg.server;
|
||||
hostDataPath = "${common.dataDir}/immich";
|
||||
version = "v3.1.0";
|
||||
in
|
||||
{
|
||||
imports = [ ./config.nix ];
|
||||
|
||||
options.selfhosted.immich.server = {
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
hostHttpPort = mkOption {
|
||||
type = types.port;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf rootCfg.enable {
|
||||
virtualisation.oci-containers.containers."${cfg.name}" = {
|
||||
image = "ghcr.io/immich-app/immich-server:${version}";
|
||||
ports = [
|
||||
"0.0.0.0:${toString cfg.hostHttpPort}:2283"
|
||||
];
|
||||
environmentFiles = [ config.sops.templates."immich.env".path ];
|
||||
environment = {
|
||||
IMMICH_VERSION = version;
|
||||
DB_HOSTNAME = rootCfg.postgresql.name;
|
||||
DB_DATABASE_NAME = rootCfg.postgresql.db;
|
||||
DB_USERNAME = rootCfg.postgresql.user;
|
||||
REDIS_HOSTNAME = rootCfg.redis.name;
|
||||
};
|
||||
volumes = [
|
||||
"${hostDataPath}/data:/data"
|
||||
"/etc/localtime:/etc/localtime:ro"
|
||||
];
|
||||
log-driver = "journald";
|
||||
extraOptions = [
|
||||
"--network=${common.network.name}"
|
||||
];
|
||||
};
|
||||
|
||||
systemd.services."${common.backend}-${cfg.name}" = {
|
||||
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"
|
||||
"${common.backend}-${rootCfg.redis.name}.service"
|
||||
];
|
||||
after = [
|
||||
"${common.backend}-${rootCfg.postgresql.name}.service"
|
||||
"${common.backend}-${rootCfg.redis.name}.service"
|
||||
];
|
||||
preStart = ''
|
||||
mkdir -p ${hostDataPath}/data
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user