nix/modules/nixos/services/containerised/imgproxy/default.nix

37 lines
1.1 KiB
Nix
Raw Normal View History

{ config, lib, ... }: {
options.snowflake.services.containerised.imgproxy = {
enable = lib.mkEnableOption "enable imgproxy";
domain = lib.mkOption {
type = lib.types.str;
description = "domain name to host imgproxy on";
};
version = lib.mkOption {
type = lib.types.str;
description = "imgproxy version to use";
};
};
config = lib.mkIf config.snowflake.services.containerised.imgproxy.enable {
virtualisation.oci-containers.containers.imgproxy = {
autoStart = true;
image =
"docker.io/darthsim/imgproxy:${config.snowflake.services.containerised.imgproxy.version}";
ports = [ "127.0.0.1:8080:8080" ];
environment = {
IMGPROXY_MAX_ANIMATION_FRAMES = "10";
IMGPROXY_USER_AGENT = "Mozilla/5.0";
};
};
services.nginx.virtualHosts."${config.snowflake.services.containerised.imgproxy.domain}" =
{
serverName = config.snowflake.services.containerised.imgproxy.domain;
enableACME = true;
forceSSL = true;
locations."/" = { proxyPass = "http://127.0.0.1:8080/"; };
};
};
}