The previous was more of a workaround not fitting in the spirit of nixos, this fixes this and makes proper modules out of them. Sadly ente-web-auth has to be build with a env var and therefore can't be configured before properly.
47 lines
884 B
Nix
47 lines
884 B
Nix
{
|
|
lib,
|
|
pkgs,
|
|
config,
|
|
namespace,
|
|
...
|
|
}:
|
|
with lib;
|
|
with lib.${namespace};
|
|
let
|
|
cfg = config.${namespace}.services.ente-auth;
|
|
in
|
|
{
|
|
options.${namespace}.services.ente-auth = {
|
|
enable = mkEnableOption "Ente-Auth";
|
|
|
|
package = mkOption {
|
|
description = "The package of Ente-Auth to use.";
|
|
type = types.package;
|
|
default = pkgs.awesome-flake.ente-web-auth;
|
|
};
|
|
|
|
port = mkOption {
|
|
description = "The port to serve Ente-Auth on.";
|
|
type = types.nullOr types.int;
|
|
default = 1338;
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
networking.firewall.allowedTCPPorts = [
|
|
cfg.port
|
|
];
|
|
|
|
services.caddy = {
|
|
enable = true;
|
|
virtualHosts = {
|
|
":${builtins.toString cfg.port}" = {
|
|
extraConfig = ''
|
|
root * ${cfg.package}
|
|
file_server
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|