summaryrefslogtreecommitdiff
path: root/modules/blog.nix
blob: 9234f4e0f2786cee8f4841d919481210ef029a17 (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
{ config, lib, inputs, pkgs, ... }: with lib; let
  cfg = config.santi-modules.services.blog;
  blog = pkgs.stdenv.mkDerivation {
    name="hugo-blog";
    src = inputs.blog;
    buildInputs = [ pkgs.hugo ];
    buildPhase = ''
      mkdir $out
      hugo --destination $out
    '';
  };
in {
  options.santi-modules.services.blog = {
    enable = mkEnableOption "Enable blog hosting";
    url = mkOption {
      type = types.str;
      default = "santi.net.br";
      description = "Url to serve blog on";
    };
  };
  config = mkIf cfg.enable {
    networking.firewall.allowedTCPPorts = [ 80 ];
    # TODO: enable SSL
    services.nginx = {
      enable = true;
      virtualHosts.${cfg.url}.root = blog;
    };
  };
}