services: add blog
This commit is contained in:
parent
5fc1b7ae74
commit
c8e9dd8535
37
services/blog.nix
Normal file
37
services/blog.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
# My blog setup
|
||||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.my.services.blog;
|
||||
domain = config.networking.domain;
|
||||
|
||||
makeHostInfo = name: {
|
||||
name = "${name}.${domain}";
|
||||
value = "/var/www/${name}";
|
||||
};
|
||||
|
||||
hostsInfo = [
|
||||
{
|
||||
name = domain;
|
||||
value = "/var/www/blog";
|
||||
}
|
||||
] ++ builtins.map makeHostInfo [ "cv" "dev" "key" ];
|
||||
|
||||
hosts = builtins.listToAttrs hostsInfo;
|
||||
|
||||
makeVirtualHost = with lib.attrsets;
|
||||
name: root: nameValuePair "${name}" {
|
||||
forceSSL = true;
|
||||
useACMEHost = "${domain}";
|
||||
inherit root;
|
||||
};
|
||||
in
|
||||
{
|
||||
options.my.services.blog = {
|
||||
enable = lib.mkEnableOption "Blog hosting";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.nginx.virtualHosts = with lib.attrsets;
|
||||
mapAttrs' makeVirtualHost hosts;
|
||||
};
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
{
|
||||
imports = [
|
||||
./backup.nix
|
||||
./blog.nix
|
||||
./gitea.nix
|
||||
./indexers.nix
|
||||
./jellyfin.nix
|
||||
|
|
Loading…
Reference in a new issue