Coder Social home page Coder Social logo

photoprism2nix's Introduction

Archived

There is now a mainline nixos module for photoprism. Use that!

NixOS module for Photoprism

This module is a fork of photoprism2nix.

Photoprism is now part of nixpkgs, this fork removes all of the photoprism build and just includes the NixOS module.

Some of the photoprism configuration is controlled through environment variables, and some of the configuration is controlled through a file: /var/lib/photoprism/storage/config/settings.yml

My configuration uses containers and bind mounts and a nginx reverse proxy for access control.

  containers = {
    PhotoPrism0 = mkPhotoPrismContainer {
      inherit pkgs photoprism2nix;
      roOriginals = "/zpool/containers/PhotoPrism0";
      port = PhotoPrism0Port;
      site = "https://example.com/photos/PhotoPrism0/";
    };
{
  pkgs,
  photoprism2nix,
  port,
  roOriginals,
  site,
}: let
  settingsFile = pkgs.writeTextFile {
    name = "photoprism-settings.yml";
    text = ''
      UI:
        Scrollbar: true
        Zoom: false
        Theme: default
        Language: en
        TimeZone: ""
      Search:
        BatchSize: 0
      Maps:
        Animate: 0
        Style: ""
      Features:
        Account: false
        Advanced: false
        Albums: false
        Archive: false
        Delete: false
        Download: true
        Edit: false
        Estimates: true
        Favorites: true
        Files: false
        Folders: true
        Import: false
        Labels: false
        Library: true
        Logs: true
        Moments: false
        People: false
        Places: false
        Private: false
        Ratings: true
        Reactions: true
        Review: true
        Search: false
        Services: false
        Settings: false
        Share: false
        Upload: false
        Videos: false
      Import:
        Path: /
        Move: false
      Index:
        Path: /
        Convert: true
        Rescan: false
        SkipArchived: false
      Stack:
        UUID: true
        Meta: true
        Name: false
      Share:
        Title: ""
      Download:
        Name: file
        Disabled: false
        Originals: true
        MediaRaw: false
        MediaSidecar: false
      Templates:
        Default: index.gohtml
    '';
  };
in {
  autoStart = true;

  bindMounts = {
    "/var/lib/photoprism/originals" = {
      hostPath = roOriginals;
      isReadOnly = true;
    };
  };

  config = {
    config,
    pkgs,
    photoprism2nin,
    ...
  }: {
    imports = [photoprism2nix.nixosModules.photoprism];

    environment.etc."resolv.conf".text = "nameserver 8.8.8.8";

    system.activationScripts.copyInConfig = {
      text = ''
        mkdir -p /var/lib/photoprism/storage/config/
        rm /var/lib/photoprism/storage/config/settings.yml
        cp ${settingsFile} /var/lib/photoprism/storage/config/settings.yml
      '';
      deps = [];
    };

    services.photoprism = {
      enable = true;
      originalsDir = "/var/lib/photoprism/originals";
      adminPassword = "xxxxxxxxxxxxxxxxx";
      settings = {
        HTTP_PORT = port;
        HTTP_HOST = "127.0.0.1";
        AUTH_MODE = "public";
        DISABE_WEBDAV = "true";
        READONLY = "true";
        DISABLE_WEBDAV = "true";
        DISABLE_SETTINGS = "true";
        DISABLE_PLACES = "true";
        SITE_URL = site;
      };
    };
  };
}
    nginx = { 
      enable = true;
      recommendedGzipSettings = true;
      recommendedProxySettings = true;
      recommendedTlsSettings = true;
      adminAddr = "[email protected]";
  
      virtualHosts = {
        "example.com" = {
	  ...

          locations."/photos/PhotoPrism0/" = {
            basicAuth = {change = "me";};
            extraConfig = ''
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header Host $host;
    
              proxy_pass http://localhost:${toString PhotoPrism0Port};
    
              proxy_buffering off;
              proxy_http_version 1.1;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection "upgrade";
    
              client_max_body_size 500M;
            '';
          };
     ...
     };

photoprism2nix's People

Contributors

gtrunsec avatar jcumming avatar meutraa avatar dependabot[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.