nixos/modules/services/huginn.nix

66 lines
2.3 KiB
Nix
Raw Normal View History

2023-11-11 19:13:16 +08:00
inputs:
{
options.nixos.services.huginn = let inherit (inputs.lib) mkOption types; in
{
enable = mkOption { type = types.bool; default = false; };
2023-11-12 17:29:40 +08:00
hostname = mkOption { type = types.nonEmptyStr; default = "huginn.chn.moe"; };
2023-11-11 19:13:16 +08:00
};
config =
let
inherit (inputs.lib) mkIf;
inherit (inputs.config.nixos.services) huginn;
in mkIf huginn.enable
{
virtualisation.oci-containers.containers.huginn =
{
2024-06-18 09:49:56 +08:00
image = "huginn/huginn:5a1509b51188e0d16868be893c983d6fcfd232a5";
2023-11-11 19:13:16 +08:00
imageFile = inputs.pkgs.dockerTools.pullImage
{
imageName = "ghcr.io/huginn/huginn";
2024-06-18 09:49:56 +08:00
imageDigest = "sha256:6f7a5b41457b94490210221a8bd3aae32d4ebfc2652f97c14919aa8036d7294e";
sha256 = "1ha6c6bwdpdl98cwwxw5fan0j77ylgaziidqhnyh6anpzq35f540";
2023-11-11 19:13:16 +08:00
finalImageName = "huginn/huginn";
2024-06-18 09:49:56 +08:00
finalImageTag = "5a1509b51188e0d16868be893c983d6fcfd232a5";
2023-11-11 19:13:16 +08:00
};
ports = [ "127.0.0.1:3000:3000/tcp" ];
extraOptions = [ "--add-host=host.docker.internal:host-gateway" ];
environmentFiles = [ inputs.config.sops.templates."huginn/env".path ];
};
sops =
{
2023-11-12 16:56:58 +08:00
templates."huginn/env".content = let placeholder = inputs.config.sops.placeholder; in
2023-11-11 19:13:16 +08:00
''
MYSQL_PORT_3306_TCP_ADDR=host.docker.internal
HUGINN_DATABASE_NAME=huginn
HUGINN_DATABASE_USERNAME=huginn
2023-11-12 16:56:58 +08:00
HUGINN_DATABASE_PASSWORD=${placeholder."mariadb/huginn"}
2023-11-11 19:13:16 +08:00
DOMAIN=${huginn.hostname}
RAILS_ENV=production
FORCE_SSL=true
2023-11-12 16:56:58 +08:00
INVITATION_CODE=${placeholder."huginn/invitationCode"}
2023-11-11 19:13:16 +08:00
SMTP_DOMAIN=mail.chn.moe
SMTP_USER_NAME=bot@chn.moe
2023-11-12 16:56:58 +08:00
SMTP_PASSWORD="${placeholder."mail/bot"}"
2023-11-11 19:13:16 +08:00
SMTP_SERVER=mail.chn.moe
SMTP_SSL=true
EMAIL_FROM_ADDRESS=bot@chn.moe
TIMEZONE=Beijing
2023-11-12 19:28:07 +08:00
DO_NOT_CREATE_DATABASE=true
2023-11-11 19:13:16 +08:00
'';
2023-11-12 16:56:58 +08:00
secrets = { "huginn/invitationCode" = {}; "mail/bot" = {}; };
2023-11-11 19:13:16 +08:00
};
nixos =
{
services =
{
nginx =
{
enable = true;
https."${huginn.hostname}".location."/".proxy = { upstream = "http://127.0.0.1:3000"; websocket = true; };
};
2023-11-12 16:56:58 +08:00
mariadb.instances.huginn = {};
2023-11-11 19:13:16 +08:00
};
};
};
}