about summary refs log tree commit diff stats
path: root/modules/by-name/at/atuin-sync/module.nix
blob: 0db2e29bc28bdb59f3b371c54cb8b4186489c52c (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
{
  config,
  lib,
  vhackPackages,
  ...
}: let
  cfg = config.vhack.atuin-sync;
in {
  options.vhack.atuin-sync = {
    enable = lib.mkEnableOption "atuin sync server";

    fqdn = lib.mkOption {
      description = "The fully qualified domain name of this instance.";
      type = lib.types.str;
      example = "atuin-sync.atuin.sh";
    };
  };

  config = lib.mkIf cfg.enable {
    vhack.nginx.enable = true;

    services = {
      nginx.virtualHosts."${cfg.fqdn}" = {
        locations."/" = {
          proxyPass = "http://127.0.0.1:${toString config.services.atuin.port}";
          recommendedProxySettings = true;
        };

        enableACME = true;
        forceSSL = true;
      };

      atuin = {
        enable = true;
        package = vhackPackages.atuin-server-only;
        host = "127.0.0.1";

        # Nobody knows about the fqdn and even if, they can only upload encrypted blobs.
        openRegistration = true;

        database.createLocally = true;
      };
    };
  };
}