mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 17:31:34 +01:00
personal-blog: Init module
This commit is contained in:
parent
4a7e655f71
commit
75c3e62cfb
1 changed files with 51 additions and 0 deletions
51
modules/system/web-services/personal-blog.nix
Normal file
51
modules/system/web-services/personal-blog.nix
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.custom.services.personal-blog;
|
||||||
|
|
||||||
|
dataDir = "/var/lib/personal-blog";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.custom.services.personal-blog = {
|
||||||
|
enable = lib.mkEnableOption "";
|
||||||
|
domain = lib.mkOption {
|
||||||
|
type = lib.types.nonEmptyStr;
|
||||||
|
default = "";
|
||||||
|
};
|
||||||
|
port = lib.mkOption {
|
||||||
|
type = lib.types.port;
|
||||||
|
default = 3890;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
meta = {
|
||||||
|
domains.list = [ cfg.domain ];
|
||||||
|
ports.tcp.list = [ cfg.port ];
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services = {
|
||||||
|
generate-blog = {
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
before = [ "caddy.service" ];
|
||||||
|
startAt = "*:0/5"; # Every 5 minutes
|
||||||
|
path = [
|
||||||
|
pkgs.nix
|
||||||
|
pkgs.git
|
||||||
|
];
|
||||||
|
script = "nix build git+https://git.sstork.dev/SebastianStork/blog?ref=main --out-link ${dataDir} --refresh";
|
||||||
|
};
|
||||||
|
|
||||||
|
caddy.after = [ "generate-blog.service" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
services.caddy.virtualHosts.":${toString cfg.port}".extraConfig = ''
|
||||||
|
root * ${dataDir}
|
||||||
|
file_server
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue