2023-09-17 19:51:08 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
inputs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
|
|
|
cfg = config.services.skynet_users;
|
|
|
|
in {
|
2023-09-15 23:04:39 +00:00
|
|
|
imports = [
|
|
|
|
./acme.nix
|
|
|
|
./dns.nix
|
|
|
|
./nginx.nix
|
|
|
|
];
|
|
|
|
|
|
|
|
options.services.skynet_users = {
|
|
|
|
host = {
|
|
|
|
ip = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
# ssh access
|
|
|
|
|
|
|
|
# allow more than admins access
|
|
|
|
services.skynet_ldap_client = {
|
|
|
|
groups = [
|
|
|
|
"skynet-admins-linux"
|
|
|
|
"skynet-users-linux"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
# Website config
|
|
|
|
skynet_acme.domains = [
|
2023-09-17 19:51:08 +00:00
|
|
|
"users.skynet.ie"
|
2023-09-15 23:04:39 +00:00
|
|
|
"*.users.skynet.ie"
|
|
|
|
];
|
|
|
|
|
|
|
|
skynet_dns.records = [
|
2023-09-17 19:51:08 +00:00
|
|
|
{
|
|
|
|
record = "users";
|
|
|
|
r_type = "CNAME";
|
|
|
|
value = cfg.host.name;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
record = "*.users";
|
|
|
|
r_type = "CNAME";
|
|
|
|
value = cfg.host.name;
|
|
|
|
}
|
2023-09-15 23:04:39 +00:00
|
|
|
];
|
|
|
|
|
2024-02-28 09:10:57 +00:00
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
vim
|
|
|
|
php
|
|
|
|
];
|
2023-09-28 10:59:51 +00:00
|
|
|
|
2023-12-22 15:52:34 +00:00
|
|
|
networking = {
|
|
|
|
defaultGateway = {
|
|
|
|
address = lib.mkDefault "193.1.96.161";
|
|
|
|
interface = lib.mkDefault "eth1";
|
|
|
|
};
|
|
|
|
};
|
2023-09-15 23:04:39 +00:00
|
|
|
|
|
|
|
# normally services cannot read home dirs
|
2023-09-17 19:51:08 +00:00
|
|
|
systemd.services.nginx.serviceConfig.ProtectHome = "read-only";
|
2023-09-15 23:04:39 +00:00
|
|
|
|
|
|
|
services.nginx.virtualHosts = {
|
2024-01-31 15:43:18 +00:00
|
|
|
"${cfg.host.ip}" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "skynet";
|
|
|
|
locations."/".return = "307 https://skynet.ie";
|
|
|
|
};
|
|
|
|
|
2023-09-15 23:04:39 +00:00
|
|
|
# main site
|
|
|
|
"*.users.skynet.ie" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "skynet";
|
|
|
|
serverName = "~^(?<user>.+)\.users\.skynet\.ie";
|
|
|
|
|
|
|
|
# username.users.skynet.ie/
|
|
|
|
# user goes:
|
|
|
|
# chmod 711 ~
|
|
|
|
# chmod -R 755 ~/public_html
|
|
|
|
|
|
|
|
locations."/" = {
|
|
|
|
alias = "/home/$user/public_html/";
|
|
|
|
index = "index.html";
|
|
|
|
extraConfig = "autoindex on;";
|
2023-10-22 20:38:24 +00:00
|
|
|
tryFiles = "$uri$args $uri$args/ /index.html";
|
2023-09-15 23:04:39 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-09-17 19:51:08 +00:00
|
|
|
}
|