nixos/modules/services/photoprism/default.nix

81 lines
1.9 KiB
Nix
Raw Normal View History

# self-hosted photo gallery
{ config, pkgs, lib, ... }:
let
cfg = config.my.services.photoprism;
domain = config.networking.domain;
in
{
2023-01-15 12:17:21 +01:00
options.my.services.photoprism = {
enable = lib.mkEnableOption (lib.mdDoc "Photoprism web server");
2023-01-15 12:17:21 +01:00
passwordFile = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
2023-01-15 12:17:21 +01:00
description = lib.mdDoc ''
Admin password file.
'';
};
2023-01-15 12:17:21 +01:00
port = lib.mkOption {
type = lib.types.port;
default = 2342;
2023-01-15 12:17:21 +01:00
description = lib.mdDoc ''
Web interface port.
'';
};
2023-01-15 12:17:21 +01:00
originalsPath = lib.mkOption {
type = lib.types.path;
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)
'';
};
2023-01-15 12:17:21 +01:00
settings = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
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.
'';
example = {
PHOTOPRISM_DEFAULT_LOCALE = "de";
PHOTOPRISM_ADMIN_USER = "root";
};
};
};
config = lib.mkIf cfg.enable {
services.photoprism = {
enable = true;
passwordFile = cfg.passwordFile;
port = cfg.port;
originalsPath = cfg.originalsPath;
settings = cfg.settings;
};
my.services.nginx.virtualHosts = [
{
subdomain = "photos";
inherit (cfg) port;
extraConfig = {
locations."/" = {
proxyWebsockets = true;
};
};
}
];
webapps.apps.photoprism = {
dashboard = {
name = "Photos";
category = "media";
icon = "image";
link = "https://photos.${domain}/library/login";
method = "get";
};
};
};
}