about summary refs log tree commit diff
path: root/modules/services/nextcloud.nix
blob: 56fcb2212e8db4a5577aa2ec5890c86715038265 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
{ config, lib, pkgs, ... }:

with lib;
let
  cfg = config.modules.services.nextcloud;
in
{
  options.modules.services.nextcloud = {
    enable = mkEnableOption "";

    secrets = {
      admin-pass = mkOption { type = types.path; };
    };
  };

  config = mkIf cfg.enable {
    services.nextcloud = {
      enable = true;

      package = pkgs.nextcloud28;
      database.createLocally = true;
      hostName = "nextcloud.internal";

      nginx.recommendedHttpHeaders = true;
      maxUploadSize = "512G";
      # https = false;

      home = "/smol/core/nextcloud";
      enableImagemagick = true;

      caching = {
        apcu = true;
        redis = true;
        memcached = true;
      };

      configureRedis = true;

      phpOptions = {
        # Fix opcache "buffer is almost full"
        "opcache.interned_strings_buffer" = 16;
        "opcache.jit" = 1255;
        "opcache.jit_buffer_size" = "128M";
        max_execution_time = 3600;
        max_input_time = 3600;
      };

      extraApps = with config.services.nextcloud.package.packages.apps; {
          inherit
            memories
            contacts
            calendar
            tasks
            bookmarks
            deck
            forms;
      };

      autoUpdateApps = {
        enable = true;
        startAt = "03:00";
      };

      extraOptions = {
        # Required for Logging App to function
        log_type = "file";

        enabledPreviewProviders = [
          ''OC\Preview\Image'' # alias for png,jpeg,gif,bmp
          ''OC\Preview\HEIC''
          ''OC\Preview\TIFF''
          ''OC\Preview\Movie''
        ];

        "memories.exiftool" = lib.getExe pkgs.exiftool;
        "memories.ffmpeg_path" = lib.getExe' pkgs.ffmpeg-headless "ffmpeg";
        "memories.ffprobe_path" = lib.getExe' pkgs.ffmpeg-headless "ffprobe";
        "memories.vod.ffmpeg" = lib.getExe' pkgs.ffmpeg-headless "ffmpeg";
        "memories.vod.ffprobe" = lib.getExe' pkgs.ffmpeg-headless "ffprobe";
      };

      config = {
        dbtype = "pgsql";
        adminuser = "admin";
        adminpassFile = cfg.secrets.admin-pass;
      };
    };

    services.postgresqlBackup.enable = true;
    environment.persistence."/persist".directories = [
      "/var/lib/postgresql"
      "/var/backup/postgresql"
    ];

    systemd.services.nextcloud-cron = {
      path = with pkgs; [ perl ];
      # preStart = "${pkgs.coreutils}/bin/chmod +x ${config.services.nextcloud.home}/store-apps/memories/bin-ext/*";
    };

  };
}