financier-nix/module.nix
Martin Puppe 8c56307c55 Add nix flake support
With this commit, we add nix flake support. Flakes are evaluated in pure
evaluation mode. The script generate.sh does not work in pure evaluation
mode since it node2nix fetches itself resources from the network. In
order to enable pure evaluation, we add the generated nix files to this
repository.
2021-09-20 00:11:34 +02:00

59 lines
1.3 KiB
Nix

{ config, lib, pkgs, system, ... }:
with lib;
let
inherit (pkgs) financier-dist;
cfg = config.services.financier;
in {
imports = [ ];
options.services.financier = {
enable = mkEnableOption "Financier";
hostName = mkOption {
type = types.str;
description = ''
Name for the virtual host for the web server.
'';
example = "example.org";
};
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";
};
};
config = mkIf cfg.enable {
nixpkgs.overlays = [ (import ./overlay.nix) ];
networking.firewall.allowedTCPPorts = [ 80 443 ];
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
}
'';
};
};
}