nixos-configs/common/services/lewa.nix

39 lines
1.0 KiB
Nix

{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.within.services.lewa;
l'ewa = pkgs.fetchzip {
url = "https://xena.greedo.xeserv.us/files/lewa-book.tar.gz";
sha256 = "0n86fq25cnqwgfp7hfzh8l1h57a1sgvafq7lyd477amgvq0drk4c";
};
in {
options.within.services.lewa = {
enable = mkEnableOption "Activates the eBook for l'ewa";
useACME = mkEnableOption "enables ACME for cert stuff";
domain = mkOption {
type = types.str;
default = "lewa.akua";
example = "lewa.cetacean.club";
description =
"The domain name that nginx should check against for HTTP hostnames";
};
};
config = mkIf cfg.enable {
services.nginx.virtualHosts."lewa" = {
serverName = "${cfg.domain}";
locations."/".root = "${l'ewa}/book";
forceSSL = cfg.useACME;
useACMEHost = "within.website";
extraConfig = ''
access_log /var/log/nginx/lewa.access.log;
'';
};
services.cfdyndns = mkIf cfg.useACME { records = [ "${cfg.domain}" ]; };
};
}