stockholm/makefu/2configs/nginx/euer.blog.nix

43 lines
1.1 KiB
Nix
Raw Normal View History

2015-10-29 08:28:27 +00:00
{ config, lib, pkgs, ... }:
2016-10-20 18:54:38 +00:00
with import <stockholm/lib>;
2015-10-29 08:28:27 +00:00
let
2015-10-29 09:55:54 +00:00
sec = toString <secrets>;
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 08:28:27 +00:00
in {
# 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 22:38:01 +00:00
services.nginx = {
2015-10-29 08:28:27 +00:00
enable = mkDefault true;
2016-12-24 22:38:01 +00:00
virtualHosts = {
"euer.krebsco.de" = {
#serverAliases = [ "blog.euer.krebsco.de" "blog.${hostname}" ];
enableACME = true;
forceSSL = true;
root = base-dir;
2015-10-29 08:28:27 +00:00
};
};
};
}