nixos/applications/skynet.ie/skynet.ie.nix

94 lines
2.3 KiB
Nix
Raw Normal View History

{
config,
pkgs,
lib,
inputs,
...
}:
with lib; let
name = "website";
cfg = config.services.skynet."${name}";
in {
imports = [
# import in past website versions, available at $year.skynet.ie
(import ./old_site.nix {year = "2009";})
(import ./old_site.nix {year = "2017";})
];
2023-07-23 02:08:56 +00:00
options.services.skynet."${name}" = {
enable = mkEnableOption "Skynet Main Website";
2023-07-23 02:08:56 +00:00
};
config = mkIf cfg.enable {
services.skynet.acme.domains = [
2023-08-11 00:44:04 +00:00
"discord.skynet.ie"
2023-09-28 16:11:35 +00:00
"public.skynet.ie"
"renew.skynet.ie"
];
services.skynet.dns.records = [
2023-07-23 02:08:56 +00:00
# means root domain, so skynet.ie
{
record = "@";
r_type = "A";
value = config.services.skynet.host.ip;
}
{
record = "discord";
r_type = "CNAME";
value = config.services.skynet.host.name;
}
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";
value = config.services.skynet.host.name;
2023-09-27 23:26:32 +00:00
}
{
record = "renew";
r_type = "CNAME";
value = config.services.skynet.host.name;
}
2023-07-23 02:08:56 +00:00
];
services.nginx = {
2023-07-23 02:08:56 +00:00
virtualHosts = {
# main site
"skynet.ie" = {
forceSSL = true;
useACMEHost = "skynet";
locations = {
2024-06-14 20:34:43 +00:00
"/".root = "${inputs.skynet_website.defaultPackage."x86_64-linux"}";
# this redirects old links to new format
"~* ~(?<username>[a-z_0-9]*)(?<files>\\S*)$" = {
priority = 1;
return = "307 https://$username.users.skynet.ie$files";
};
};
};
2023-07-23 02:08:56 +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";
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}";
locations."/".extraConfig = "autoindex on;";
2023-09-27 23:26:32 +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
};
};
};
}