nixos-config/2configs/nginx/euer.blog.nix

45 lines
1.1 KiB
Nix
Raw Normal View History

2015-10-29 09:28:27 +01:00
{ config, lib, pkgs, ... }:
with pkgs.stockholm.lib;
2015-10-29 09:28:27 +01:00
let
2015-10-29 10:55:54 +01: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 09:28:27 +01: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 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;
default = true;
2016-12-24 23:38:01 +01:00
root = base-dir;
2015-10-29 09:28:27 +01:00
};
};
};
state = [ base-dir ];
2015-10-29 09:28:27 +01:00
}