Initial checkin

This commit is contained in:
niten 2024-02-07 14:09:35 -08:00
commit 792b11846c
2 changed files with 116 additions and 0 deletions

17
flake.nix Normal file
View File

@ -0,0 +1,17 @@
{
description = "Immich running in a container";
inputs = {
nixpkgs.url = "nixpkgs/nixos-23.11";
arion.url = "github:hercules-ci/arion";
};
outputs = { self, nixpkgs, arion, ... }: {
nixosModules = rec {
default = immichContainer;
immichContainer = { ... }: {
imports = [ arion.nixosModules.arion ./immich-container.nix ];
};
};
};
}

99
immich-container.nix Normal file
View File

@ -0,0 +1,99 @@
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.services.immichContainer;
in {
options.services.immichContainer = with types; {
enable =
mkEnableOption "Enable Immich photo server running in a container.";
state-directory = mkOption {
type = str;
description = "Path at which to store server state.";
};
store-directory = mkOption {
type = str;
description = "Path at which to store bulk server data.";
};
images = {
immich = mkOption {
type = str;
description = "Immich server docker image to use.";
};
immich-ml = mkOption {
type = str;
description = "Immich Machine Learning docker image to use.";
};
redis = mkOption {
type = str;
description = "Redis server docker image to use.";
};
postgresql = mkOption {
type = str;
description = "Postgresql server docker image to use.";
};
};
};
config = {
virtualisation.arion.projects.nextcloud.settings = let
image = { ... }: {
project.name = "immich";
services = {
immich = {
service = {
image = cfg.images.immich;
restart = "always";
ports = [ "${cfg.port}:3001" ];
command = [ "start.sh" "immich" ];
depends_on = [ "redis" "database" ];
volumes = [
"${cfg.store-directory}:/usr/src/app/upload"
"/etc/localtime:/etc/localtime:ro"
];
};
};
immich-microservices = {
service = {
image = cfg.images.immich;
restart = "always";
command = [ "start.sh" "microservices" ];
depends_on = [ "redis" "database" ];
volumes = [
"${cfg.store-directory}:/usr/src/app/upload"
"/etc/localtime:/etc/localtime:ro"
];
};
};
immich-ml = {
service = {
image = cfg.images.immich-ml;
restart = "always";
volumes = [ "${cfg.state-directory}/model-cache:/cache" ];
};
};
redis.service = {
image = cfg.images.redis;
restart = "always";
volumes = [ "${cfg.state-directory}/redis:/var/lib/redis" ];
};
database = {
service = {
image = cfg.images.postgresql;
restart = "always";
depends_on = [ "redis" "database" ];
volumes =
[ "${cfg.state-directory}/database:/var/lib/postgresql/data" ];
};
};
};
};
in imports [ image ];
};
}