From d2f8537695338c6b186bb0d52489c66c6ae83b8d Mon Sep 17 00:00:00 2001 From: Leonardo Santiago Date: Mon, 16 Sep 2024 20:20:16 -0300 Subject: add blog module --- modules/blog.nix | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 modules/blog.nix (limited to 'modules/blog.nix') diff --git a/modules/blog.nix b/modules/blog.nix new file mode 100644 index 0000000..9234f4e --- /dev/null +++ b/modules/blog.nix @@ -0,0 +1,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; + }; + }; +} -- cgit v1.2.3