added immich to the homelab.
This commit is contained in:
		
							parent
							
								
									478d5760bd
								
							
						
					
					
						commit
						11f6c18f13
					
				
					 5 changed files with 66 additions and 0 deletions
				
			
		| 
						 | 
					@ -80,6 +80,14 @@ in {
 | 
				
			||||||
              description = "Movies";
 | 
					              description = "Movies";
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            Immich = {
 | 
				
			||||||
 | 
					              icon = "sh-immich.svg";
 | 
				
			||||||
 | 
					              href = "https://pics.venberg.xyz";
 | 
				
			||||||
 | 
					              siteMonitor = "https://pics.venberg.xyz";
 | 
				
			||||||
 | 
					              description = "Pictures";
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
          {
 | 
					          {
 | 
				
			||||||
            Grocy = {
 | 
					            Grocy = {
 | 
				
			||||||
              icon = "sh-grocy.svg";
 | 
					              icon = "sh-grocy.svg";
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										43
									
								
								configs/nixos/immich.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								configs/nixos/immich.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,43 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  inputs,
 | 
				
			||||||
 | 
					  config,
 | 
				
			||||||
 | 
					  pkgs,
 | 
				
			||||||
 | 
					  lib,
 | 
				
			||||||
 | 
					  ...
 | 
				
			||||||
 | 
					}: let
 | 
				
			||||||
 | 
					  port = 2283;
 | 
				
			||||||
 | 
					  cfg = config.services.immich;
 | 
				
			||||||
 | 
					  backupPrepare = pkgs.writeShellScriptBin "postgres-immich-dump" ''
 | 
				
			||||||
 | 
					    set -euxo pipefail
 | 
				
			||||||
 | 
					    ${lib.getExe pkgs.sudo} -iu postgres pg_dump -Fc immich > /backup/immich_psql.dump
 | 
				
			||||||
 | 
					  '';
 | 
				
			||||||
 | 
					in {
 | 
				
			||||||
 | 
					  # make sure your postgres database is on big storage, and if using zfs, create with the following settings:
 | 
				
			||||||
 | 
					  # zfs create -o recordsize=8K -o primarycache=metadata -o mountpoint=/var/lib/postgresql <pool>/postgresql
 | 
				
			||||||
 | 
					  services.immich = {
 | 
				
			||||||
 | 
					    enable = true;
 | 
				
			||||||
 | 
					    port = port;
 | 
				
			||||||
 | 
					    machine-learning.enable = true;
 | 
				
			||||||
 | 
					    mediaLocation = "/storage/immich";
 | 
				
			||||||
 | 
					    settings = null;
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					  imports = [
 | 
				
			||||||
 | 
					    ./nginx.nix
 | 
				
			||||||
 | 
					  ];
 | 
				
			||||||
 | 
					  services.nginx.virtualHosts."pics.venberg.xyz" = {
 | 
				
			||||||
 | 
					    enableACME = true;
 | 
				
			||||||
 | 
					    forceSSL = true;
 | 
				
			||||||
 | 
					    locations."/" = {
 | 
				
			||||||
 | 
					      proxyPass = "http://localhost:${toString port}";
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					  host.restic.backups.immich = {
 | 
				
			||||||
 | 
					    preBackupCommands = lib.getExe backupPrepare;
 | 
				
			||||||
 | 
					    paths = [
 | 
				
			||||||
 | 
					      "/backup/immich_psql.dump"
 | 
				
			||||||
 | 
					      "${cfg.mediaLocation}/library"
 | 
				
			||||||
 | 
					      "${cfg.mediaLocation}/upload"
 | 
				
			||||||
 | 
					      "${cfg.mediaLocation}/profile"
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -31,6 +31,7 @@ inputs.nixpkgs.lib.nixosSystem {
 | 
				
			||||||
    ../../configs/nixos/miniserve-tmp-upload.nix
 | 
					    ../../configs/nixos/miniserve-tmp-upload.nix
 | 
				
			||||||
    ../../configs/nixos/minecraft-docker.nix
 | 
					    ../../configs/nixos/minecraft-docker.nix
 | 
				
			||||||
    ../../configs/nixos/nginx-static.nix
 | 
					    ../../configs/nixos/nginx-static.nix
 | 
				
			||||||
 | 
					    ../../configs/nixos/immich.nix
 | 
				
			||||||
    ({
 | 
					    ({
 | 
				
			||||||
      config,
 | 
					      config,
 | 
				
			||||||
      pkgs,
 | 
					      pkgs,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -69,6 +69,14 @@
 | 
				
			||||||
          mountpoint = "/storage";
 | 
					          mountpoint = "/storage";
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
        datasets = {
 | 
					        datasets = {
 | 
				
			||||||
 | 
					          database={
 | 
				
			||||||
 | 
					            type = "zfs_fs";
 | 
				
			||||||
 | 
					            options = {
 | 
				
			||||||
 | 
					              mountpoint ="/postgres";
 | 
				
			||||||
 | 
					              recordsize = "8K";
 | 
				
			||||||
 | 
					              primarycache="metadata";
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					          };
 | 
				
			||||||
          backup = {
 | 
					          backup = {
 | 
				
			||||||
            type = "zfs_fs";
 | 
					            type = "zfs_fs";
 | 
				
			||||||
            options = {
 | 
					            options = {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -50,6 +50,11 @@
 | 
				
			||||||
              type = lib.types.listOf lib.types.path;
 | 
					              type = lib.types.listOf lib.types.path;
 | 
				
			||||||
              description = "paths to back up.";
 | 
					              description = "paths to back up.";
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
 | 
					            user = lib.mkOption {
 | 
				
			||||||
 | 
					              type = lib.types.str;
 | 
				
			||||||
 | 
					              description = "what user to run the backup under.";
 | 
				
			||||||
 | 
					              default = "root";
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
            preBackupCommands = lib.mkOption {
 | 
					            preBackupCommands = lib.mkOption {
 | 
				
			||||||
              type = lib.types.nullOr lib.types.lines;
 | 
					              type = lib.types.nullOr lib.types.lines;
 | 
				
			||||||
              description = "commands to run before the start of the backup.";
 | 
					              description = "commands to run before the start of the backup.";
 | 
				
			||||||
| 
						 | 
					@ -139,6 +144,7 @@
 | 
				
			||||||
              backupPrepareCommand = backup.preBackupCommands;
 | 
					              backupPrepareCommand = backup.preBackupCommands;
 | 
				
			||||||
              backupCleanupCommand = backup.postBackupCommands;
 | 
					              backupCleanupCommand = backup.postBackupCommands;
 | 
				
			||||||
              paths = backup.paths;
 | 
					              paths = backup.paths;
 | 
				
			||||||
 | 
					              user = backup.user;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          )
 | 
					          )
 | 
				
			||||||
          cfg.backups
 | 
					          cfg.backups
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue