aboutsummaryrefslogtreecommitdiff
path: root/systems/eldiron/websites/cloud/default.nix
blob: c859f326bde4a20243c73559f133b2fd90d2b069 (plain) (blame)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
{ lib, pkgs, config,  ... }:
let
  ncfg = config.myServices.tools.cloud.farm.instances.immae;
  env = config.myEnv.tools.nextcloud;
  cfg = config.myServices.websites.tools.cloud;
in {
  options.myServices.websites.tools.cloud = {
    enable = lib.mkEnableOption "enable cloud website";
  };

  config = lib.mkIf cfg.enable {
    services.borgBackup.profiles.global.includedPaths = [
      "nextcloud/appdata_occ80acffb591"
      "nextcloud/files_external"
      "nextcloud/config"
      #"nextcloud/gpxpod"
      "nextcloud/.ocdata"
      "nextcloud/.htaccess"
      "nextcloud/index.html"
    ];
    myServices.dns.zones."immae.eu".subdomains.cloud =
      with config.myServices.dns.helpers; ips servers.eldiron.ips.main;

    myServices.chatonsProperties.hostings.nextcloud = {
      file.datetime = "2022-08-21T19:50:00";
      hosting = {
        name = "Nextcloud";
        description = "The self-hosted productivity platform that keeps you in control";
        website = "https://cloud.immae.eu/";
        logo = "https://cloud.immae.eu/core/img/favicon.ico";
        type = "INSTANCE";
        status.level = "OK";
        status.description = "OK";
        registration.load = "OPEN";
        install.type = "PACKAGE";
      };
    };
    myServices.chatonsProperties.services.nextcloud = {
      file.datetime = "2022-08-21T19:50:00";
      service = {
        name = "Nextcloud";
        description = "The self-hosted productivity platform that keeps you in control";
        website = "https://cloud.immae.eu/";
        logo = "https://cloud.immae.eu/core/img/favicon.ico";
        status.level = "OK";
        status.description = "OK";
        registration."" = ["MEMBER" "CLIENT"];
        registration.load = "OPEN";
        install.type = "PACKAGE";
        guide.user = "https://www.immae.eu/docs/nextcloud.html";
      };
      software = {
        name = "Nextcloud";
        website = "https://nextcloud.com/";
        license.url = "https://github.com/nextcloud/server/blob/master/COPYING";
        license.name = "GNU Affero General Public License v3.0";
        version = ncfg.rootDir.version;
        source.url = "https://github.com/nextcloud/server";
        modules = map (a: a.appName) ncfg.rootDir.apps;
      };
    };

    myServices.tools.cloud.farm.instances.immae = {
      nextcloud = pkgs.webapps-nextcloud_27.override ({
        # Allow /index.php redirects
        postInstall = ''
          cd $out
          ${pkgs.php81}/bin/php ${./add-htaccess.php} /
        '';
      });
      apps = a: [
        a.side_menu a.audioplayer a.bookmarks a.calendar a.carnet a.contacts
        a.cookbook a.deck a.extract a.files_markdown a.files_mindmap
        a.gpxpod a.keeweb a.maps a.metadata a.music
        a.notes a.passman a.polls a.spreed a.tasks
      ];
      varDir = "/var/lib/nextcloud";
      secretsPath = "webapps/tools-nextcloud";
      phpPackage = pkgs.php81;
      # Be careful when editing that: config from here takes
      # precedence over the regular one, but if a key got removed, it my
      # still exist in the default config file
      config = let
        env = config.myEnv.tools.nextcloud;
      in {
        "dbtype" = "pgsql";
        "dbname" = env.postgresql.database;
        "dbhost" = env.postgresql.socket;
        "dbport" = "";
        "dbtableprefix" = "oc_";
        "dbuser" = env.postgresql.user;
        "dbpassword" = env.postgresql.password;

        "instanceid" = env.instance_id;
        "passwordsalt" = env.password_salt;
        "secret" = env.secret;

        "trusted_domains" = [ "cloud.immae.eu" ];
        "overwrite.cli.url" = "https://cloud.immae.eu";

        "lost_password_link" = "disabled";

        "remember_login_cookie_lifetime" = 60*60*24*30;
        "session_keepalive" = true;
        "session_lifefime" = 60*60*24*30;

        "maxZipInputSize" = 0;
        "allowZipDownload" = true;

        # set by Carnet
        "has_rebuilt_cache" = true;

        "memcache.distributed" = "\\OC\\Memcache\\Redis";
        "memcache.locking" = "\\OC\\Memcache\\Redis";
        "filelocking.enabled" = true;
        "redis" = {
          "host" = env.redis.socket;
          "port" = 0;
          "dbindex" = env.redis.db;
        };

        "ldapIgnoreNamingRules" = false;
        "ldapProviderFactory" = "\\OCA\\User_LDAP\\LDAPProviderFactory";

        "mail_smtpmode" = "sendmail";
        "mail_smtphost" = "127.0.0.1";
        "mail_smtpname" = "";
        "mail_smtppassword" = "";
        "mail_from_address" = "nextcloud";
        "mail_smtpauth" = false;
        "mail_domain" = "tools.immae.eu";
      };
    };
    services.websites.env.tools.modules = [ "proxy_fcgi" ];

    security.acme.certs.eldiron.extraDomainNames = [ "cloud.immae.eu" ];
    services.websites.env.tools.vhostConfs.cloud = {
      certName    = "eldiron";
      hosts       = ["cloud.immae.eu" ];
      root        = ncfg.rootDir;
      extraConfig = [
        ncfg.vhost
      ];
    };

    myServices.monitoring.fromMasterActivatedPlugins = [ "http" ];
    myServices.monitoring.fromMasterObjects.service = [
      {
        service_description = "owncloud website is running on cloud.immae.eu";
        host_name = config.hostEnv.fqdn;
        use = "external-web-service";
        check_command = ["check_https" "cloud.immae.eu" "/" "a safe home for all your data"];

        servicegroups = "webstatus-webapps";
        _webstatus_name = "Nextcloud";
        _webstatus_url = "https://cloud.immae.eu";
      }
    ];
  };
}