aboutsummaryrefslogtreecommitdiff
path: root/nix/per-host/photos/configuration.nix
blob: a9058cf76f91509b2e194f09da4d6e66d156f505 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{ config, pkgs, modulesPath, lib, system, ... }:

{
  config = {
    sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
    sops.defaultSopsFile = ../../secrets/photos.yaml;

    networking.hostName = "photos";

    hardware.graphics.enable = true;
    hardware.nvidia = {
      modesetting.enable = true;
      nvidiaPersistenced = true;
      powerManagement.enable = false;
      powerManagement.finegrained = false;
      open = false;
      nvidiaSettings = true;
      package = config.boot.kernelPackages.nvidiaPackages.legacy_580;
    };
    services.xserver.videoDrivers = [ "nvidia" ];

    nixpkgs.config.allowUnfree = true;

    # Immich 3.1.x ML is broken, we a patch to remove OpenVINO
    # See: https://github.com/immich-app/immich/issues/25830
    services.immich.package = pkgs.immich.overrideAttrs (old: {
      passthru = (old.passthru or { }) // {
        machine-learning = pkgs.immich.machine-learning.overrideAttrs (old: {
          postPatch = (old.postPatch or "") + ''
            substituteInPlace immich_ml/models/constants.py \
              --replace-fail '"OpenVINOExecutionProvider",' ""
            substituteInPlace test_main.py \
              --replace-fail "def test_sets_openvino_provider_if_available" "def skipped_sets_openvino_provider_if_available"
          '';
        });
      };
    });

    services.immich = {
      enable = true;
      host = "0.0.0.0";
      openFirewall = true;
      environment.LD_LIBRARY_PATH = "/run/opengl-driver/lib";
      accelerationDevices = null;
      settings = {
        server.externalDomain = "https://photos.kumardamani.net";
        ffmpeg.accel = "nvenc";
        ffmpeg.accelDecode = true;
        machineLearning.ocr.enabled = false;
        library.scan = {
          enabled = true;
          cronExpression = "0 * * * *";
        };
        image.previewSize = 1080;
      };
    };

    services.immich.environment.IMMICH_LOG_LEVEL = "warn";

    fileSystems = {
      "/mnt/data/kumar/legacy-media" = {
        device = "nas.bacala:/mnt/tank/customers/kumar/legacy-media";
        fsType = "nfs";
      };
      "/mnt/data/kumar/phone/camera" = {
        device = "nas.bacala:/mnt/tank/customers/kumar/phone/camera";
        fsType = "nfs";
      };
      "/mnt/data/kumar/phone/pics" = {
        device = "nas.bacala:/mnt/tank/customers/kumar/phone/pics";
        fsType = "nfs";
      };
      "/mnt/data/stephanie/legacy-media" = {
        device = "nas.bacala:/mnt/tank/customers/stephanie/legacy-media";
        fsType = "nfs";
      };
      "/mnt/data/stephanie/phone/camera" = {
        device = "nas.bacala:/mnt/tank/customers/stephanie/phone/camera";
        fsType = "nfs";
      };
      "/mnt/data/stephanie/phone/pics" = {
        device = "nas.bacala:/mnt/tank/customers/stephanie/phone/pics";
        fsType = "nfs";
      };
    };
  };
}