infra/pastila/srv.nix

54 lines
1.2 KiB
Nix
Raw Normal View History

2024-06-01 10:53:00 +00:00
{ config, lib, pkgs, ... }:
2024-06-01 17:19:37 +00:00
let
up_dir = "/srv/up";
isomorphisme_dir = "/srv/isomorphis.me";
2024-06-01 17:19:37 +00:00
in
2024-06-01 10:53:00 +00:00
{
services.nginx.enable = true;
2024-06-01 16:45:55 +00:00
# nginx runs under ProtectHome=true which disallows reading anywhere
# in /home. So we need to use a different location.
2024-06-01 10:53:00 +00:00
users.users."up" = {
isNormalUser = true;
2024-06-01 17:19:37 +00:00
home = up_dir;
2024-06-01 17:34:21 +00:00
# group = config.services.nginx.group;
group = "nginx";
2024-06-01 17:19:37 +00:00
# Unsure why this is broken, but couldn't make things work without
# creating the directory by hand.
# TODO: this might have been because I used up_dir = /srv/up before;
# maybe this would work now?
2024-06-01 17:19:37 +00:00
# createHome = true;
# homeMode = "750";
2024-06-01 10:53:00 +00:00
};
services.nginx.virtualHosts."srv.isomorphis.me" = {
forceSSL = true;
enableACME = true;
2024-06-01 17:19:37 +00:00
root = up_dir;
2024-06-01 18:22:49 +00:00
locations = {
2024-06-01 17:19:37 +00:00
"/" = {
extraConfig = "autoindex on;";
};
"/.ssh" = {
return = "403";
};
"/i/" = {
extraConfig = "autoindex off;";
};
2024-06-01 10:53:00 +00:00
};
};
2024-06-01 18:22:49 +00:00
services.nginx.virtualHosts."isomorphis.me" = {
forceSSL = true;
enableACME = true;
locations."/" = {
root = isomorphisme_dir;
};
};
system.activationScripts."srv-permissions" = ''
chown -R up:nginx /srv/up
chown -R nginx:nginx /srv/isomorphis.me
'';
2024-06-01 10:53:00 +00:00
}