1
0
mirror of https://git.oat.zone/dark-firepit/dotfiles synced 2024-11-26 06:08:48 +01:00
git.oat.zone--dark-firepit-.../modules/services/libreddit.nix
Jill "oatmealine" Monoids 4f97f5d72f some minor refactors
2023-05-01 23:19:11 +02:00

46 lines
1.0 KiB
Nix

{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.modules.services.libreddit;
in {
options.modules.services.libreddit = {
enable = mkOption {
type = types.bool;
default = false;
};
domain = mkOption {
type = types.str;
default = "libreddit.oat.zone";
};
port = mkOption {
type = types.port;
default = 1590;
};
};
config = mkIf cfg.enable {
services = {
libreddit = {
enable = true;
package = pkgs.libreddit;
port = cfg.port;
};
nginx.enable = true;
nginx.virtualHosts."${cfg.domain}" = {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://localhost:${toString cfg.port}";
extraConfig = ''
if ($http_user_agent = 'Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)') {
return 302 $scheme://proxy.knotty.dev$request_uri;
}
'';
};
};
};
};
}