2023-09-17 19:51:08 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
inputs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
2024-05-30 13:59:20 +00:00
|
|
|
name = "website";
|
|
|
|
cfg = config.services.skynet."${name}";
|
2023-09-17 19:51:08 +00:00
|
|
|
in {
|
2024-06-14 19:38:46 +00:00
|
|
|
imports = [];
|
2023-07-23 02:08:56 +00:00
|
|
|
|
2024-05-30 13:59:20 +00:00
|
|
|
options.services.skynet."${name}" = {
|
2024-05-30 16:55:29 +00:00
|
|
|
enable = mkEnableOption "Skynet Main Website";
|
2023-07-23 02:08:56 +00:00
|
|
|
};
|
|
|
|
|
2024-05-30 16:55:29 +00:00
|
|
|
config = mkIf cfg.enable {
|
2024-05-30 12:34:59 +00:00
|
|
|
services.skynet.acme.domains = [
|
2023-08-06 19:09:15 +00:00
|
|
|
# the root one is already covered by teh certificate
|
2024-06-14 19:36:16 +00:00
|
|
|
"2017.skynet.ie"
|
|
|
|
"2009.skynet.ie"
|
2023-08-11 00:44:04 +00:00
|
|
|
"discord.skynet.ie"
|
2023-09-28 16:11:35 +00:00
|
|
|
"public.skynet.ie"
|
2023-09-30 18:22:58 +00:00
|
|
|
"renew.skynet.ie"
|
2023-08-06 19:09:15 +00:00
|
|
|
];
|
|
|
|
|
2024-05-30 12:25:52 +00:00
|
|
|
services.skynet.dns.records = [
|
2023-07-23 02:08:56 +00:00
|
|
|
# means root domain, so skynet.ie
|
2023-09-17 19:51:08 +00:00
|
|
|
{
|
|
|
|
record = "@";
|
|
|
|
r_type = "A";
|
2024-05-30 16:55:29 +00:00
|
|
|
value = config.services.skynet.host.ip;
|
2023-09-17 19:51:08 +00:00
|
|
|
}
|
|
|
|
{
|
2024-06-14 19:36:16 +00:00
|
|
|
record = "2017";
|
|
|
|
r_type = "CNAME";
|
|
|
|
value = config.services.skynet.host.name;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
record = "2009";
|
2023-09-17 19:51:08 +00:00
|
|
|
r_type = "CNAME";
|
2024-05-30 16:55:29 +00:00
|
|
|
value = config.services.skynet.host.name;
|
2023-09-17 19:51:08 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
record = "discord";
|
|
|
|
r_type = "CNAME";
|
2024-05-30 16:55:29 +00:00
|
|
|
value = config.services.skynet.host.name;
|
2023-09-17 19:51:08 +00:00
|
|
|
}
|
2023-09-27 23:26:32 +00:00
|
|
|
{
|
2023-09-28 16:11:35 +00:00
|
|
|
record = "public";
|
2023-09-27 23:26:32 +00:00
|
|
|
r_type = "CNAME";
|
2024-05-30 16:55:29 +00:00
|
|
|
value = config.services.skynet.host.name;
|
2023-09-27 23:26:32 +00:00
|
|
|
}
|
2023-09-30 18:22:58 +00:00
|
|
|
{
|
|
|
|
record = "renew";
|
|
|
|
r_type = "CNAME";
|
2024-05-30 16:55:29 +00:00
|
|
|
value = config.services.skynet.host.name;
|
2023-09-30 18:22:58 +00:00
|
|
|
}
|
2023-07-23 02:08:56 +00:00
|
|
|
];
|
|
|
|
|
2023-09-16 00:35:26 +00:00
|
|
|
services.nginx = {
|
2023-07-23 02:08:56 +00:00
|
|
|
virtualHosts = {
|
|
|
|
# main site
|
|
|
|
"skynet.ie" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "skynet";
|
2024-04-20 03:55:07 +00:00
|
|
|
locations = {
|
2024-06-14 19:36:16 +00:00
|
|
|
# this alwas points to teh current version of teh site
|
|
|
|
"/".root = "${inputs.skynet_website_2017.defaultPackage."x86_64-linux"}";
|
2024-04-20 03:55:07 +00:00
|
|
|
|
|
|
|
# this redirects old links to new format
|
2024-05-24 15:13:49 +00:00
|
|
|
"~* ~(?<username>[a-z_0-9]*)(?<files>\\S*)$" = {
|
2024-04-20 03:55:07 +00:00
|
|
|
priority = 1;
|
|
|
|
return = "307 https://$username.users.skynet.ie$files";
|
|
|
|
};
|
|
|
|
};
|
2023-09-04 17:03:48 +00:00
|
|
|
};
|
2023-07-23 02:08:56 +00:00
|
|
|
|
2024-06-14 19:36:16 +00:00
|
|
|
# 2017 to now
|
|
|
|
"2017.skynet.ie" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "skynet";
|
|
|
|
root = "${inputs.skynet_website_2017.defaultPackage."x86_64-linux"}";
|
|
|
|
};
|
|
|
|
|
|
|
|
# archive of teh site as it was ~2009 to 2017
|
|
|
|
"2009.skynet.ie" = {
|
2023-07-23 02:08:56 +00:00
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "skynet";
|
2024-06-14 19:36:16 +00:00
|
|
|
root = "${inputs.skynet_website_2009.defaultPackage."x86_64-linux"}";
|
2023-07-23 02:08:56 +00:00
|
|
|
};
|
2023-08-11 00:44:04 +00:00
|
|
|
|
2023-09-27 23:26:32 +00:00
|
|
|
# a custom discord url, because we are too cheap otehrwise
|
2023-08-11 00:44:04 +00:00
|
|
|
"discord.skynet.ie" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "skynet";
|
2023-09-18 19:13:56 +00:00
|
|
|
locations."/".return = "307 https://discord.gg/mkuKJkCuyM";
|
2023-08-11 00:44:04 +00:00
|
|
|
};
|
2023-09-27 23:26:32 +00:00
|
|
|
|
2023-09-28 16:11:35 +00:00
|
|
|
"public.skynet.ie" = {
|
2023-09-27 23:26:32 +00:00
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "skynet";
|
2023-09-28 16:11:35 +00:00
|
|
|
root = "${inputs.compsoc_public.packages.x86_64-linux.default}";
|
2023-09-27 23:47:33 +00:00
|
|
|
locations."/".extraConfig = "autoindex on;";
|
2023-09-27 23:26:32 +00:00
|
|
|
};
|
2023-09-30 18:22:58 +00:00
|
|
|
|
|
|
|
# for alumni members to renew their account
|
|
|
|
"renew.skynet.ie" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "skynet";
|
|
|
|
root = "${inputs.skynet_website_renew.defaultPackage."x86_64-linux"}";
|
|
|
|
};
|
2023-07-23 02:08:56 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-09-17 19:51:08 +00:00
|
|
|
}
|