2021-02-07 22:07:24 +01:00
|
|
|
# My blog setup
|
|
|
|
{ config, lib, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.my.services.blog;
|
|
|
|
domain = config.networking.domain;
|
|
|
|
|
2021-08-24 23:05:10 +02:00
|
|
|
makeHostInfo = subdomain: {
|
|
|
|
root = "/var/www/${subdomain}";
|
2021-02-07 22:07:24 +01:00
|
|
|
};
|
|
|
|
|
2023-12-25 19:25:08 +01:00
|
|
|
hostsInfo = lib.flip lib.genAttrs makeHostInfo [ "cv" "dev" "key" ];
|
2021-02-07 22:07:24 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.my.services.blog = {
|
|
|
|
enable = lib.mkEnableOption "Blog hosting";
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
2021-08-24 23:05:10 +02:00
|
|
|
services.nginx.virtualHosts = {
|
|
|
|
# This is not a subdomain, cannot use my nginx wrapper module
|
|
|
|
${domain} = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = domain;
|
|
|
|
root = "/var/www/blog";
|
2022-12-18 12:59:42 +01:00
|
|
|
|
|
|
|
# http://www.gnuterrypratchett.com/
|
|
|
|
extraConfig = ''
|
|
|
|
add_header X-Clacks-Overhead "GNU Terry Pratchett";
|
|
|
|
'';
|
2021-08-24 23:05:10 +02:00
|
|
|
};
|
2023-03-31 23:53:11 +02:00
|
|
|
|
|
|
|
# Dummy vhost to redirect all unknown (sub-)domains to my blog
|
|
|
|
"_" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = domain;
|
|
|
|
default = true;
|
|
|
|
|
2024-03-05 22:45:18 +01:00
|
|
|
locations."/".return = "302 https://${domain}$request_uri";
|
2023-03-31 23:53:11 +02:00
|
|
|
};
|
2021-08-24 23:05:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
# Those are all subdomains, no problem
|
|
|
|
my.services.nginx.virtualHosts = hostsInfo;
|
2021-02-07 22:07:24 +01:00
|
|
|
};
|
|
|
|
}
|