aboutsummaryrefslogtreecommitdiff
path: root/modules/private/websites/ressourcerie_banon/cryptpad.nix
blob: 961302da866d5f42dbd870a8b4e1bebcd755c174 (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
{ lib, pkgs, config, ... }:
let
  cfg = config.myServices.websites.ressourcerie_banon.cryptpad;
  configFile = "${pkgs.cryptpad}/lib/node_modules/cryptpad/config/config.example.js";
in {
  options.myServices.websites.ressourcerie_banon.cryptpad.enable = lib.mkEnableOption "Enable Ressourcerie Banon’s cryptpad";

  config = lib.mkIf cfg.enable {
    systemd.services.cryptpad-ressourcerie_banon = {
      description = "Cryptpad Banon Service";
      wantedBy = [ "multi-user.target" ];
      after = [ "networking.target" ];
      serviceConfig = {
        DynamicUser = true;
        Environment = [
          "CRYPTPAD_CONFIG=${configFile}"
          "HOME=%S/cryptpad/ressourcerie_banon"
        ];
        ExecStart = "${pkgs.cryptpad}/bin/cryptpad";
        PrivateTmp = true;
        Restart = "always";
        StateDirectory = "cryptpad/ressourcerie_banon";
        WorkingDirectory = "%S/cryptpad/ressourcerie_banon";
      };
    };
    services.websites.env.production.vhostConfs.ressourcerie_banon_cryptpad = {
      certName = "ressourcerie_banon";
      addToCerts = true;
      hosts = ["pad.le-garage-autonome.org"];
      root = null;
    };
  };
}