summaryrefslogtreecommitdiff
path: root/nix/module.nix
blob: decb6861c2a30b02d4c6c07edce7cc6cd2aa303c (plain)
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
{
  config,
  lib,
  pkgs,
  ...
}: let
  cfg = config.services.getchoo-website;
  inherit (lib) mkEnableOption mkIf mkOption types;
in {
  options.services.getchoo-website = {
    enable = mkEnableOption "enable getchoo-website";

    hostName = mkOption {
      type = types.str;
      description = "hostname for nginx virtualHost";
    };

    location = mkOption {
      type = types.str;
      default = "/";
      description = "location to serve on virtualHost";
    };
  };

  config.services.nginx = mkIf cfg.enable {
    enable = true;
    virtualHosts.${cfg.hostName} = {
      locations.${cfg.location} = {
        root = "${pkgs.getchoo-website}/libexec/getchoo-website/deps/getchoo-website/dist/";
        index = "index.html";
        tryFiles = "$uri =404";
      };
    };
  };
}