2020-09-15 11:13:24 +02:00
|
|
|
{ config, lib, pkgs, system, ... }:
|
|
|
|
|
with lib;
|
|
|
|
|
let
|
2021-09-20 00:11:34 +02:00
|
|
|
inherit (pkgs) financier-dist;
|
2020-09-15 11:13:24 +02:00
|
|
|
cfg = config.services.financier;
|
2021-07-31 16:58:29 +02:00
|
|
|
in {
|
|
|
|
|
imports = [ ];
|
2020-09-15 11:13:24 +02:00
|
|
|
|
|
|
|
|
options.services.financier = {
|
|
|
|
|
enable = mkEnableOption "Financier";
|
|
|
|
|
|
|
|
|
|
hostName = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
description = ''
|
2021-02-20 03:21:26 +01:00
|
|
|
Name for the virtual host for the web server.
|
2020-09-15 11:13:24 +02:00
|
|
|
'';
|
|
|
|
|
example = "example.org";
|
|
|
|
|
};
|
2021-02-20 03:21:26 +01:00
|
|
|
|
|
|
|
|
server = mkOption {
|
|
|
|
|
type = types.enum [ "nginx" "caddy" ];
|
|
|
|
|
description = ''
|
|
|
|
|
The web server to be used for serving Financier. Either "nginx"
|
|
|
|
|
or "caddy".
|
|
|
|
|
'';
|
|
|
|
|
default = "caddy";
|
|
|
|
|
example = "example.org";
|
|
|
|
|
};
|
2020-09-15 11:13:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-09-20 00:11:34 +02:00
|
|
|
nixpkgs.overlays = [ (import ./overlay.nix) ];
|
|
|
|
|
|
2020-09-15 11:13:24 +02:00
|
|
|
networking.firewall.allowedTCPPorts = [ 80 443 ];
|
|
|
|
|
|
2021-02-20 03:21:26 +01:00
|
|
|
services.nginx = mkIf (cfg.server == "nginx") {
|
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
|
|
virtualHosts."${cfg.hostName}" = {
|
|
|
|
|
forceSSL = true;
|
|
|
|
|
enableACME = true;
|
|
|
|
|
root = financier-dist;
|
|
|
|
|
locations."/".tryFiles = "$uri $uri/ /index.html";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
services.caddy = mkIf (cfg.server == "caddy") {
|
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
|
|
config = ''
|
|
|
|
|
${cfg.hostName} {
|
|
|
|
|
root * ${financier-dist}
|
|
|
|
|
file_server
|
|
|
|
|
try_files {path} {path}/ /index.html
|
|
|
|
|
}
|
|
|
|
|
'';
|
2020-09-15 11:13:24 +02:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|