{config, ...}: let
  vars = import ../../../../vars.nix;
in {
  virtualisation.arion = {
    projects.wiki.settings = {
      imports = [./arion-compose.nix];
    };
  };

  sops.secrets."wiki/aws_access_key_id" = {
    owner = vars.user;
  };
  sops.secrets."wiki/aws_secret_access_key" = {
    owner = vars.user;
  };
  sops.secrets."wiki/oidc_client_id" = {
    owner = vars.user;
  };
  sops.secrets."wiki/oidc_client_secret" = {
    owner = vars.user;
  };
  sops.secrets."wiki/secret_key" = {
    owner = vars.user;
  };
  sops.secrets."wiki/utils_secret" = {
    owner = vars.user;
  };
  sops.secrets."wiki/db_user" = {
    owner = vars.user;
  };
  sops.secrets."wiki/db_pass" = {
    owner = vars.user;
  };
  sops.secrets."wiki/db_name" = {
    owner = vars.user;
  };

  sops.templates."wiki-postgres.env" = {
    path = "/home/${vars.user}/.docker/wiki/postgres.env";
    owner = vars.user;
    mode = "0775";
    content = ''
      POSTGRES_PASSWORD="${config.sops.placeholder."wiki/db_pass"}"
      POSTGRES_USER="${config.sops.placeholder."wiki/db_user"}"
      POSTGRES_DB="${config.sops.placeholder."wiki/db_name"}"
    '';
  };

  sops.templates."wiki-outline.env" = {
    path = "/home/${vars.user}/.docker/wiki/outline.env";
    owner = vars.user;
    mode = "0775";
    content = ''
      SECRET_KEY="${config.sops.placeholder."wiki/secret_key"}"
      UTILS_SECRET="${config.sops.placeholder."wiki/utils_secret"}"

      OIDC_CLIENT_ID="${config.sops.placeholder."wiki/oidc_client_id"}"
      OIDC_CLIENT_SECRET="${config.sops.placeholder."wiki/oidc_client_secret"}"

      AWS_ACCESS_KEY_ID="${config.sops.placeholder."wiki/aws_access_key_id"}"
      AWS_SECRET_ACCESS_KEY="${config.sops.placeholder."wiki/aws_secret_access_key"}"

      DATABASE_URL="postgres://${config.sops.placeholder."wiki/db_user"}:${config.sops.placeholder."wiki/db_pass"}@postgres:5432/${config.sops.placeholder."wiki/db_name"}"
      DATABASE_URL_TEST="postgres://${config.sops.placeholder."wiki/db_user"}:${config.sops.placeholder."wiki/db_pass"}@postgres:5432/${config.sops.placeholder."wiki/db_name"}"
    '';
  };
}