summary refs log blame commit diff stats
path: root/system/services/libreddit/default.nix
blob: e527ec23c01f2d69a8b8326931e5e03a188f270b (plain) (tree)
1
2
3
4
5
6
7
 
                



                                





                                   
    
                        
                                   
                
                          
                         
    
 

                                                                                                       







                                                                                              
 
{
  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;
    };
  };
}