From 5c5daa49b7af4a42ae5d91c20eb73abd166bda26 Mon Sep 17 00:00:00 2001 From: Jimbo Date: Tue, 10 Sep 2024 14:45:28 -0400 Subject: [PATCH] Add photoprism properly --- flake.lock | 18 ++++++++--------- nixos/hardware/machines/server.nix | 5 +++++ nixos/server.nix | 1 + nixos/server/mariadb.nix | 11 +++++++++-- nixos/server/photoprism.nix | 30 +++++++++++++++++++++++++++++ nixos/server/wireguard.nix | 4 ---- secrets.nix | Bin 2175 -> 2174 bytes 7 files changed, 54 insertions(+), 15 deletions(-) create mode 100644 nixos/server/photoprism.nix diff --git a/flake.lock b/flake.lock index 45532cb..6765d2f 100644 --- a/flake.lock +++ b/flake.lock @@ -167,11 +167,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1725716377, - "narHash": "sha256-7NzW9O/cAw7iWzRfh7Oo/SuSudL4a1YTKS6yoh3tMck=", + "lastModified": 1725885300, + "narHash": "sha256-5RLEnou1/GJQl+Wd+Bxaj7QY7FFQ9wjnFq1VNEaxTmc=", "owner": "nixos", "repo": "nixos-hardware", - "rev": "04a1cda0c1725094a4db703cccbb956b7558f5a6", + "rev": "166dee4f88a7e3ba1b7a243edb1aca822f00680e", "type": "github" }, "original": { @@ -298,11 +298,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1725693463, - "narHash": "sha256-ZPzhebbWBOr0zRWW10FfqfbJlan3G96/h3uqhiFqmwg=", + "lastModified": 1725826545, + "narHash": "sha256-L64N1rpLlXdc94H+F6scnrbuEu+utC03cDDVvvJGOME=", "owner": "nixos", "repo": "nixpkgs", - "rev": "68e7dce0a6532e876980764167ad158174402c6f", + "rev": "f4c846aee8e1e29062aa8514d5e0ab270f4ec2f9", "type": "github" }, "original": { @@ -314,11 +314,11 @@ }, "nur": { "locked": { - "lastModified": 1725854666, - "narHash": "sha256-Peccz5solKBUlGtN5vfWHxbd0Mxks+feh1TU/A7hZTg=", + "lastModified": 1725914786, + "narHash": "sha256-IUEPseZohbNJi9eFFWUhTnkpceZLMj0B62TtCkLo2ZY=", "owner": "nix-community", "repo": "NUR", - "rev": "4448858f13f127db4c8055e2bf6fe6e1257ba8ea", + "rev": "b121603cbc4551eda8c055bae01d08e9ecedb529", "type": "github" }, "original": { diff --git a/nixos/hardware/machines/server.nix b/nixos/hardware/machines/server.nix index b0c065d..cd9eb34 100644 --- a/nixos/hardware/machines/server.nix +++ b/nixos/hardware/machines/server.nix @@ -86,6 +86,11 @@ fsType = "none"; options = [ "bind" ]; }; + "/var/lib/private/photoprism/originals" = { + device = "/export/JimboNFS/Photos/Galleries"; + fsType = "none"; + options = [ "bind" ]; + }; }; swapDevices = [ { device = "/dev/disk/by-uuid/ec422cad-bf93-4b15-b989-2c807f1073a4"; } diff --git a/nixos/server.nix b/nixos/server.nix index 3cfb4c3..132a325 100644 --- a/nixos/server.nix +++ b/nixos/server.nix @@ -33,6 +33,7 @@ ./server/nfs.nix ./server/nginx.nix ./server/owncast.nix + ./server/photoprism.nix #./server/pixelfed.nix ./server/minecraft ./server/vaultwarden.nix diff --git a/nixos/server/mariadb.nix b/nixos/server/mariadb.nix index fc4b8a1..8848e80 100644 --- a/nixos/server/mariadb.nix +++ b/nixos/server/mariadb.nix @@ -3,8 +3,9 @@ enable = true; package = pkgs.mariadb; dataDir = "/var/lib/mysql"; - initialDatabases = [ - { name = "minecraft"; } + ensureDatabases = [ + "minecraft" + "photoprism" ]; ensureUsers = [ { @@ -13,6 +14,12 @@ "minecraft.*" = "ALL PRIVILEGES"; }; } + { + name = "photoprism"; + ensurePermissions = { + "photoprism.*" = "ALL PRIVILEGES"; + }; + } ]; }; } diff --git a/nixos/server/photoprism.nix b/nixos/server/photoprism.nix new file mode 100644 index 0000000..c66fc24 --- /dev/null +++ b/nixos/server/photoprism.nix @@ -0,0 +1,30 @@ +{outputs, ...}: { + # Photoprism + services = { + photoprism = { + enable = true; + port = 2342; + originalsPath = "/var/lib/private/photoprism/originals"; + address = "0.0.0.0"; + settings = { + PHOTOPRISM_ADMIN_USER = "jimbo"; + PHOTOPRISM_ADMIN_PASSWORD = "${outputs.secrets.prismAdminPass}"; + PHOTOPRISM_DEFAULT_LOCALE = "en"; + PHOTOPRISM_DATABASE_DRIVER = "mysql"; + PHOTOPRISM_DATABASE_NAME = "photoprism"; + PHOTOPRISM_DATABASE_SERVER = "/run/mysqld/mysqld.sock"; + PHOTOPRISM_DATABASE_USER = "photoprism"; + PHOTOPRISM_SITE_URL = "https://gallery.${outputs.secrets.jimDomain}"; + PHOTOPRISM_SITE_TITLE = "Jimbo's PhotoPrism"; + }; + }; + nginx.virtualHosts."gallery.${outputs.secrets.jimDomain}" = { + enableACME = true; + forceSSL = true; + locations."/" = { + proxyPass = "http://127.0.0.1:2342"; + proxyWebsockets = true; + }; + }; + }; +} diff --git a/nixos/server/wireguard.nix b/nixos/server/wireguard.nix index ef646a4..4bad3e2 100644 --- a/nixos/server/wireguard.nix +++ b/nixos/server/wireguard.nix @@ -25,10 +25,6 @@ in { publicKey = outputs.secrets.wirePixel9Pub; allowedIPs = [ "10.100.0.2/32" ]; } - { # Jimbo Pixel 4 - publicKey = outputs.secrets.wirePixel4Pub; - allowedIPs = [ "10.100.0.3/32" ]; - } ]; }; }; diff --git a/secrets.nix b/secrets.nix index 7918850dd7d116b00ebd2e889c515332f82688cd..b2f7f352eec323930d0bcce12c4d27a376b8c6c3 100644 GIT binary patch literal 2174 zcmV-^2!ZziM@dveQdv+`02Y4j0Gt4_>u`}&|7V^MUJno`0t!*#zuKP6oP5~HrtNO323VmuF62Z z*=|d?+PcaedB&{|6%U_fCZbndskyak6$ZHi&J@fkxQ6%C`_*xCL^3*|ZPm&O+9bio zp-QO3a_!}xd@+Z@A-2SuhACwLos*T51rb#DA>bv5n~t^V3Vb!`NI(^j`Lh-0C_U~u z2+u!d`+Uh893%v`1yao_!BPZl-pA4}%O@>c)5RoSZ4TE01=V%Vs=>RBdivDOeN|s>}#FM_t3nyJF77YF17N<3QeZc$rm zSyVf1_hy3`d~yJ~*)v_II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