| 
									
										
										
										
											2022-12-25 12:24:28 +01:00
										 |  |  | # self-hosted photo gallery | 
					
						
							| 
									
										
										
										
											2023-11-07 22:00:00 +01:00
										 |  |  | { config, lib, ... }: | 
					
						
							| 
									
										
										
										
											2022-12-25 12:24:28 +01:00
										 |  |  | let | 
					
						
							|  |  |  |   cfg = config.my.services.photoprism; | 
					
						
							| 
									
										
										
										
											2023-11-07 23:13:51 +01:00
										 |  |  |   inherit (config.networking) domain; | 
					
						
							| 
									
										
										
										
											2022-12-25 12:24:28 +01:00
										 |  |  | in | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2023-01-15 12:17:21 +01:00
										 |  |  |   options.my.services.photoprism = { | 
					
						
							|  |  |  |     enable = lib.mkEnableOption (lib.mdDoc "Photoprism web server"); | 
					
						
							| 
									
										
										
										
											2022-12-25 12:24:28 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-15 12:17:21 +01:00
										 |  |  |     passwordFile = lib.mkOption { | 
					
						
							|  |  |  |       type = lib.types.nullOr lib.types.path; | 
					
						
							| 
									
										
										
										
											2022-12-25 12:24:28 +01:00
										 |  |  |       default = null; | 
					
						
							| 
									
										
										
										
											2023-01-15 12:17:21 +01:00
										 |  |  |       description = lib.mdDoc ''
 | 
					
						
							|  |  |  |         Admin password file. | 
					
						
							|  |  |  |       '';
 | 
					
						
							| 
									
										
										
										
											2022-12-25 12:24:28 +01:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-15 12:17:21 +01:00
										 |  |  |     port = lib.mkOption { | 
					
						
							|  |  |  |       type = lib.types.port; | 
					
						
							| 
									
										
										
										
											2022-12-25 12:24:28 +01:00
										 |  |  |       default = 2342; | 
					
						
							| 
									
										
										
										
											2023-01-15 12:17:21 +01:00
										 |  |  |       description = lib.mdDoc ''
 | 
					
						
							|  |  |  |         Web interface port. | 
					
						
							|  |  |  |       '';
 | 
					
						
							| 
									
										
										
										
											2022-12-25 12:24:28 +01:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-15 12:17:21 +01:00
										 |  |  |     originalsPath = lib.mkOption { | 
					
						
							|  |  |  |       type = lib.types.path; | 
					
						
							| 
									
										
										
										
											2022-12-25 12:24:28 +01:00
										 |  |  |       default = null; | 
					
						
							|  |  |  |       example = "/data/photos"; | 
					
						
							| 
									
										
										
										
											2023-01-15 12:17:21 +01:00
										 |  |  |       description = lib.mdDoc ''
 | 
					
						
							|  |  |  |         Storage path of your original media files (photos and videos) | 
					
						
							|  |  |  |       '';
 | 
					
						
							| 
									
										
										
										
											2022-12-25 12:24:28 +01:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-15 12:17:21 +01:00
										 |  |  |     settings = lib.mkOption { | 
					
						
							|  |  |  |       type = lib.types.attrsOf lib.types.str; | 
					
						
							| 
									
										
										
										
											2022-12-25 12:24:28 +01:00
										 |  |  |       default = { }; | 
					
						
							|  |  |  |       description = lib.mdDoc ''
 | 
					
						
							| 
									
										
										
										
											2023-01-16 22:45:53 +01:00
										 |  |  |         Extra photoprism config options. See [the getting-started guide](https://docs.photoprism.app/getting-started/config-options/) for available options. | 
					
						
							| 
									
										
										
										
											2022-12-25 12:24:28 +01:00
										 |  |  |       '';
 | 
					
						
							|  |  |  |       example = { | 
					
						
							|  |  |  |         PHOTOPRISM_DEFAULT_LOCALE = "de"; | 
					
						
							|  |  |  |         PHOTOPRISM_ADMIN_USER = "root"; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   config = lib.mkIf cfg.enable { | 
					
						
							| 
									
										
										
										
											2023-06-18 22:51:24 +02:00
										 |  |  |     services.photoprism = { | 
					
						
							|  |  |  |       enable = true; | 
					
						
							| 
									
										
										
										
											2024-07-28 21:08:02 +02:00
										 |  |  |       inherit (cfg) | 
					
						
							|  |  |  |         passwordFile | 
					
						
							|  |  |  |         port | 
					
						
							|  |  |  |         originalsPath | 
					
						
							|  |  |  |         settings | 
					
						
							|  |  |  |         ; | 
					
						
							| 
									
										
										
										
											2022-12-25 12:24:28 +01:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     my.services.nginx.virtualHosts = [ | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         subdomain = "photos"; | 
					
						
							|  |  |  |         inherit (cfg) port; | 
					
						
							|  |  |  |         extraConfig = { | 
					
						
							|  |  |  |           locations."/" = { | 
					
						
							|  |  |  |             proxyWebsockets = true; | 
					
						
							|  |  |  |           }; | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     webapps.apps.photoprism = { | 
					
						
							|  |  |  |       dashboard = { | 
					
						
							|  |  |  |         name = "Photos"; | 
					
						
							|  |  |  |         category = "media"; | 
					
						
							|  |  |  |         icon = "image"; | 
					
						
							| 
									
										
										
										
											2023-11-12 20:39:44 +01:00
										 |  |  |         url = "https://photos.${domain}/library/login"; | 
					
						
							| 
									
										
										
										
											2022-12-25 12:24:28 +01:00
										 |  |  |         method = "get"; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | } |