nix

configuration files that power my machines
Log | Files | Refs | README | LICENSE

redlib.nix (1340B)


      1 {
      2   config,
      3   lib,
      4   haravara,
      5   ...
      6 }: let
      7   cfg = config.services.haravara.redlib;
      8 in {
      9   options.services.haravara.redlib = {
     10     enable = lib.mkEnableOption "Redlib Reddit Frontend";
     11     port = lib.mkOption {
     12       type = lib.types.port;
     13       default = 7828;
     14     };
     15     domain = lib.mkOption {
     16       type = lib.types.str;
     17     };
     18     tailnetPort = lib.mkOption {
     19       type = lib.types.nullOr lib.types.port;
     20       default = null;
     21     };
     22     authLabel = haravara.authLabelOption;
     23   };
     24 
     25   config = lib.mkIf cfg.enable {
     26     virtualisation.oci-containers = {
     27       backend = "podman";
     28 
     29       containers.redlib = {
     30         image = "ghcr.io/silvenga/redlib@sha256:5b7b92744ca153c75bef1f5b6b5ffb6985a230c91019d722a88ec758b15f502d";
     31         ports = ["127.0.0.1:${toString cfg.port}:8080"];
     32         environment = {
     33           REDLIB_DEFAULT_SHOW_NSFW = "off";
     34           REDLIB_DEFAULT_HIDE_HLS_NOTIFICATION = "on";
     35         };
     36       };
     37     };
     38 
     39     services.caddy.virtualHosts =
     40       {
     41         "${cfg.domain}".extraConfig = ''
     42           ${haravara.mkAuthImport cfg.authLabel}
     43           reverse_proxy 127.0.0.1:${toString cfg.port}
     44         '';
     45       }
     46       // lib.optionalAttrs (cfg.tailnetPort != null) {
     47         ":${toString cfg.tailnetPort}".extraConfig = ''
     48           reverse_proxy 127.0.0.1:${toString cfg.port}
     49         '';
     50       };
     51   };
     52 }