dotfiles/nixos/services/pub.nix

30 lines
835 B
Nix
Raw Normal View History

2016-01-28 02:59:31 +01:00
{ config, pkgs, lib, ... }:
2021-05-29 18:05:31 +02:00
let cfg = config.services.yorick.public;
in {
2018-03-11 18:28:25 +01:00
options.services.yorick.public = {
enable = lib.mkEnableOption "public hosting";
2020-05-21 17:39:38 +02:00
vhost = lib.mkOption { type = lib.types.str; };
2018-03-11 18:28:25 +01:00
};
2016-12-25 00:14:47 +01:00
#imports = [../modules/nginx.nix];
2018-03-11 18:28:25 +01:00
config = lib.mkIf cfg.enable {
2021-05-23 17:19:28 +02:00
systemd.services.nginx.serviceConfig = {
ProtectHome = "tmpfs";
BindReadOnlyPaths = [ "/home/public/public" ];
};
2016-01-28 02:59:31 +01:00
users.extraUsers.public = {
home = "/home/public";
useDefaultShell = true;
2021-05-29 18:05:31 +02:00
openssh.authorizedKeys.keys = with (import ../sshkeys.nix); [ public ];
2016-01-28 02:59:31 +01:00
createHome = true;
};
2018-03-11 18:28:25 +01:00
services.nginx.virtualHosts.${cfg.vhost} = {
2016-12-25 00:14:47 +01:00
forceSSL = true;
enableACME = true;
locations."/" = {
root = "/home/public/public";
index = "index.html";
2016-07-29 19:04:28 +02:00
};
2016-12-25 00:14:47 +01:00
};
2016-01-28 02:59:31 +01:00
};
}