2015-10-29 09:28:27 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
2023-07-02 16:05:52 +02:00
|
|
|
with pkgs.stockholm.lib;
|
2015-10-29 09:28:27 +01:00
|
|
|
let
|
2015-10-29 10:55:54 +01:00
|
|
|
sec = toString <secrets>;
|
2015-11-05 12:31:09 +01:00
|
|
|
hostname = config.krebs.build.host.name;
|
|
|
|
user = config.services.nginx.user;
|
|
|
|
group = config.services.nginx.group;
|
|
|
|
base-dir = "/var/www/blog.euer";
|
2015-10-29 09:28:27 +01:00
|
|
|
in {
|
2015-11-05 12:31:09 +01:00
|
|
|
# Prepare Blog directory
|
|
|
|
systemd.services.prepare-euer-blog = {
|
|
|
|
wantedBy = [ "local-fs.target" ];
|
|
|
|
before = [ "nginx.service" ];
|
|
|
|
serviceConfig = {
|
|
|
|
# do nothing if the base dir already exists
|
|
|
|
ExecStart = pkgs.writeScript "prepare-euer-blog-service" ''
|
|
|
|
#!/bin/sh
|
|
|
|
if ! test -d "${base-dir}" ;then
|
|
|
|
mkdir -p "${base-dir}"
|
|
|
|
chown ${user}:${group} "${base-dir}"
|
|
|
|
chmod 700 "${base-dir}"
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = "yes";
|
|
|
|
TimeoutSec = "0";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-12-24 23:38:01 +01:00
|
|
|
services.nginx = {
|
2015-10-29 09:28:27 +01:00
|
|
|
enable = mkDefault true;
|
2016-12-24 23:38:01 +01:00
|
|
|
virtualHosts = {
|
|
|
|
"euer.krebsco.de" = {
|
|
|
|
#serverAliases = [ "blog.euer.krebsco.de" "blog.${hostname}" ];
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
2022-06-06 21:22:25 +02:00
|
|
|
default = true;
|
2016-12-24 23:38:01 +01:00
|
|
|
root = base-dir;
|
2015-10-29 09:28:27 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2018-10-21 23:16:34 +02:00
|
|
|
state = [ base-dir ];
|
2015-10-29 09:28:27 +01:00
|
|
|
}
|