summary refs log tree commit diff stats
path: root/system/services/libreddit/default.nix
blob: e527ec23c01f2d69a8b8326931e5e03a188f270b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{
  pkgs-unstable,
  config,
  lib,
  ...
}: let
  domain = "libreddit.vhack.eu";
  cfg = config.services.libreddit;

  # Taken from nixpkgs module
  args = lib.concatStringsSep " " [
    "--port ${toString cfg.port}"
    "--address ${cfg.address}"
  ];
in {
  services.libreddit = {
    enable = true;
    package = pkgs-unstable.redlib;
    port = 8080;
    address = "127.0.0.1";
    openFirewall = false;
  };

  # Force systemd service to use correct binary
  systemd.services.libreddit.serviceConfig.ExecStart = lib.mkForce "${lib.getExe cfg.package} ${args}";

  services.nginx = {
    enable = true;
    virtualHosts.${domain} = {
      locations."/".proxyPass = "http://127.0.0.1:${toString config.services.libreddit.port}";

      enableACME = lib.mkDefault true;
      forceSSL = lib.mkDefault true;
    };
  };
}