Switch from arion to manual

This commit is contained in:
niten 2024-05-21 10:56:23 -07:00
parent 931231a450
commit 975316a114
1 changed files with 33 additions and 20 deletions

View File

@ -1,7 +1,27 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib; with lib;
let cfg = config.services.immichMlContainer; let
cfg = config.services.immichMlContainer;
immichMlConfigYaml = pkgs.writeJSON "immich-ml-compose.yml" {
version = "3.4";
networks.default.name = "immich-ml";
volumes = { };
services.immich-ml = {
image =
"ghcr.io/immich-app/immich-machine-learning:${cfg.immich-version}-cuda";
deploy.resources.reservations.devices = [{
driver = "nvidia";
count = 1;
capabilities = [ "gpu" ];
}];
ports = [ "${cfg.port}:3003" ];
restart = "always";
volumes = [ "${cfg.state-directory}:/cache" ];
};
};
in { in {
options.services.immichMlContainer = with types; { options.services.immichMlContainer = with types; {
enable = mkEnableOption "Enable machine learning container."; enable = mkEnableOption "Enable machine learning container.";
@ -31,27 +51,20 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
systemd.tmpfiles.rules = [ "d ${cfg.state-directory} 0750 root root - -" ]; systemd = {
services.immich-machine-learning = {
virtualisation.arion.projects.immich-ml.settings = let after = [ "network-online.target" ];
image = { ... }: { before = [ "nginx.service" ];
project.name = "immich-ml"; path = with pkgs; [ podman-compose ];
services.immich-ml = { serviceConfig = {
image.rawConfig.deploy.resources.reservations.devices = [{ ExecStart = pkgs.writeShellScript "immich-machine-learning" ''
driver = "nvidia"; podman-compose -f ${immichMlConfigYaml}
count = 1; '';
capabilities = [ "gpu" ];
}];
service = {
image =
"ghcr.io/immich-app/immich-machine-learning:${cfg.immich-version}-cuda";
restart = "always";
ports = [ "${toString cfg.port}:3003" ];
volumes = [ "${cfg.state-directory}:/cache" ];
};
}; };
}; };
in { imports = [ image ]; };
tmpfiles.rules = [ "d ${cfg.state-directory} 0750 root root - -" ];
};
services.nginx = { services.nginx = {
enable = true; enable = true;