nixos/modules/services/send.nix

52 lines
1.7 KiB
Nix
Raw Normal View History

2023-11-10 23:34:36 +08:00
inputs:
{
options.nixos.services.send = 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 = "send.chn.moe"; };
2023-11-10 23:34:36 +08:00
};
config =
let
inherit (inputs.lib) mkIf;
inherit (inputs.config.nixos.services) send;
in mkIf send.enable
{
virtualisation.oci-containers.containers.send =
{
image = "timvisee/send:1ee4951";
imageFile = inputs.pkgs.dockerTools.pullImage
{
2023-11-11 19:13:16 +08:00
imageName = "registry.gitlab.com/timvisee/send";
2023-11-10 23:34:36 +08:00
imageDigest = "sha256:1ee495161f176946e6e4077e17be2b8f8634c2d502172cc530a8cd5affd7078f";
sha256 = "1dimqga35c2ka4advhv3v60xcsdrhc6c4hh21x36fbyhk90n2vzs";
finalImageName = "timvisee/send";
finalImageTag = "1ee4951";
};
ports = [ "127.0.0.1:1443:1443/tcp" ];
volumes = [ "send:/uploads" ];
extraOptions = [ "--add-host=host.docker.internal:host-gateway" ];
environmentFiles = [ inputs.config.sops.templates."send/env".path ];
};
sops =
{
templates."send/env".content =
''
BASE_URL=https://${send.hostname}
MAX_FILE_SIZE=17179869184
REDIS_HOST=host.docker.internal
REDIS_PORT=9184
REDIS_PASSWORD=${inputs.config.sops.placeholder."redis/send"}
'';
};
2024-09-17 14:09:54 +08:00
nixos.services =
2023-11-10 23:34:36 +08:00
{
2024-09-17 14:09:54 +08:00
nginx =
2023-11-10 23:34:36 +08:00
{
2024-09-17 14:09:54 +08:00
enable = true;
https."${send.hostname}".location."/".proxy = { upstream = "http://127.0.0.1:1443"; websocket = true; };
2023-11-10 23:34:36 +08:00
};
2024-09-17 14:09:54 +08:00
redis.instances.send = { user = "root"; port = 9184; };
2023-11-10 23:34:36 +08:00
};
};
}