2025-12-07 01:38:13 -06:00
|
|
|
{
|
|
|
|
|
flake,
|
2025-12-07 04:37:17 -06:00
|
|
|
lib,
|
2025-12-07 01:38:13 -06:00
|
|
|
...
|
|
|
|
|
}:
|
|
|
|
|
let
|
|
|
|
|
inherit (flake.config.people) user0;
|
|
|
|
|
serviceCfg = {
|
|
|
|
|
name = "photoprism";
|
|
|
|
|
};
|
|
|
|
|
in
|
|
|
|
|
{
|
|
|
|
|
photoprismVM =
|
|
|
|
|
{
|
|
|
|
|
user,
|
|
|
|
|
ip,
|
|
|
|
|
mac,
|
|
|
|
|
userMac,
|
|
|
|
|
ssh,
|
|
|
|
|
}:
|
|
|
|
|
{
|
|
|
|
|
microvm.vms = {
|
|
|
|
|
"${serviceCfg.name}-${user}" = {
|
|
|
|
|
autostart = true;
|
|
|
|
|
restartIfChanged = true;
|
|
|
|
|
config = {
|
|
|
|
|
system.stateVersion = "24.05";
|
|
|
|
|
time.timeZone = "America/Winnipeg";
|
|
|
|
|
users.users.root.openssh.authorizedKeys.keys = flake.config.people.users.${user0}.sshKeys;
|
|
|
|
|
services = {
|
|
|
|
|
${serviceCfg.name} = {
|
|
|
|
|
enable = true;
|
|
|
|
|
settings = {
|
|
|
|
|
PHOTOPRISM_ADMIN_USER = user;
|
|
|
|
|
PHOTOPRISM_DEFAULT_LOCAL = "en";
|
|
|
|
|
};
|
|
|
|
|
passwordFile = "/run/secrets/${user}-pass";
|
2025-12-07 04:37:17 -06:00
|
|
|
storagePath = "/var/lib/${serviceCfg.name}";
|
2025-12-07 01:38:13 -06:00
|
|
|
originalsPath = "/var/lib/${serviceCfg.name}-media";
|
|
|
|
|
importPath = "photos";
|
2025-12-07 04:37:17 -06:00
|
|
|
address = "0.0.0.0";
|
2025-12-07 01:38:13 -06:00
|
|
|
};
|
|
|
|
|
openssh = {
|
|
|
|
|
enable = true;
|
|
|
|
|
settings = {
|
|
|
|
|
PasswordAuthentication = false;
|
|
|
|
|
PermitRootLogin = "prohibit-password";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2025-12-07 04:37:17 -06:00
|
|
|
users.users.photoprism = {
|
|
|
|
|
isSystemUser = true;
|
|
|
|
|
group = "photoprism";
|
|
|
|
|
home = "/var/lib/photoprism";
|
|
|
|
|
};
|
|
|
|
|
users.groups.photoprism = { };
|
|
|
|
|
|
2025-12-07 01:38:13 -06:00
|
|
|
networking.firewall.allowedTCPPorts = [
|
|
|
|
|
22
|
|
|
|
|
2342
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
systemd = {
|
|
|
|
|
services = {
|
2025-12-07 04:37:17 -06:00
|
|
|
photoprism = {
|
|
|
|
|
serviceConfig = {
|
|
|
|
|
DynamicUser = lib.mkForce false;
|
|
|
|
|
User = serviceCfg.name;
|
|
|
|
|
Group = serviceCfg.name;
|
|
|
|
|
};
|
|
|
|
|
};
|
2025-12-07 01:38:13 -06:00
|
|
|
systemd-networkd.wantedBy = [
|
|
|
|
|
"multi-user.target"
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
network = {
|
|
|
|
|
enable = true;
|
|
|
|
|
networks."20-lan" = {
|
|
|
|
|
matchConfig.Name = "enp0s5";
|
|
|
|
|
addresses = [
|
|
|
|
|
{ Address = "${ip}/24"; }
|
|
|
|
|
];
|
|
|
|
|
routes = [
|
|
|
|
|
{
|
|
|
|
|
Destination = "0.0.0.0/0";
|
|
|
|
|
Gateway = "192.168.50.1";
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
dns = [
|
|
|
|
|
"1.1.1.1"
|
|
|
|
|
"8.8.8.8"
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2025-12-07 04:37:17 -06:00
|
|
|
# tmpfiles.rules = [
|
|
|
|
|
# "d /var/lib/${serviceCfg.name} 0755 ${serviceCfg.name} ${serviceCfg.name} -"
|
|
|
|
|
# "d /var/lib/${serviceCfg.name}-media 0755 ${serviceCfg.name} ${serviceCfg.name} -"
|
|
|
|
|
# "d /var/lib/${serviceCfg.name}-media/photos 0755 ${serviceCfg.name} ${serviceCfg.name} -"
|
|
|
|
|
# ];
|
2025-12-07 01:38:13 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
microvm = {
|
|
|
|
|
vcpu = 1;
|
|
|
|
|
mem = 512;
|
|
|
|
|
hypervisor = "qemu";
|
|
|
|
|
interfaces = [
|
|
|
|
|
{
|
|
|
|
|
type = "tap";
|
|
|
|
|
id = "vm-pp-${user}";
|
|
|
|
|
mac = mac;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
type = "user";
|
|
|
|
|
id = "vmuser-photo";
|
|
|
|
|
mac = userMac;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
forwardPorts = [
|
|
|
|
|
{
|
|
|
|
|
from = "host";
|
|
|
|
|
host.port = ssh;
|
|
|
|
|
guest.port = 22;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
shares = [
|
|
|
|
|
{
|
|
|
|
|
mountPoint = "/nix/.ro-store";
|
|
|
|
|
proto = "virtiofs";
|
|
|
|
|
source = "/nix/store";
|
|
|
|
|
tag = "read_only_nix_store";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
mountPoint = "/var/lib/${serviceCfg.name}";
|
|
|
|
|
proto = "virtiofs";
|
|
|
|
|
source = "/mnt/storage/users/${user}/guests/${serviceCfg.name}";
|
|
|
|
|
tag = "${serviceCfg.name}_${user}_data";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
mountPoint = "/var/lib/${serviceCfg.name}-media";
|
|
|
|
|
proto = "virtiofs";
|
|
|
|
|
source = "/mnt/storage/users/${user}/home/media";
|
|
|
|
|
tag = "${serviceCfg.name}_${user}_media";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
mountPoint = "/run/secrets";
|
|
|
|
|
proto = "virtiofs";
|
|
|
|
|
source = "/run/secrets/${serviceCfg.name}";
|
|
|
|
|
tag = "host_secrets";
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
|
"d /mnt/storage/users/${user}/guests/${serviceCfg.name} 0751 microvm wheel - -"
|
|
|
|
|
"d /mnt/storage/users/${user}/home/media/photos 0751 microvm wheel - -"
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
sops.secrets = {
|
|
|
|
|
"${serviceCfg.name}/${user}-pass" = {
|
|
|
|
|
owner = "root";
|
|
|
|
|
mode = "0600";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|