option_refactor #4
22 changed files with 325 additions and 205 deletions
|
|
@ -6,7 +6,39 @@
|
||||||
networking.interfaces.enp2s0.wakeOnLan.enable = true;
|
networking.interfaces.enp2s0.wakeOnLan.enable = true;
|
||||||
|
|
||||||
niksos = {
|
niksos = {
|
||||||
server = true;
|
# server = true;
|
||||||
|
server = {
|
||||||
|
baseDomain = "jsw.tf";
|
||||||
|
derek-bot.enable = true;
|
||||||
|
forgejo = {
|
||||||
|
enable = true;
|
||||||
|
subDomain = "git";
|
||||||
|
};
|
||||||
|
immich = {
|
||||||
|
enable = true;
|
||||||
|
subDomain = "photos";
|
||||||
|
};
|
||||||
|
jsw-bot = {
|
||||||
|
enable = true;
|
||||||
|
subDomain = "dc";
|
||||||
|
};
|
||||||
|
nextcloud = {
|
||||||
|
enable = true;
|
||||||
|
subDomain = "cloud";
|
||||||
|
};
|
||||||
|
stalwart = {
|
||||||
|
enable = true;
|
||||||
|
subDomain = "mail";
|
||||||
|
};
|
||||||
|
zitadel = {
|
||||||
|
enable = true;
|
||||||
|
subDomain = "z";
|
||||||
|
};
|
||||||
|
site = {
|
||||||
|
enable = true;
|
||||||
|
subDomain = "";
|
||||||
|
};
|
||||||
|
};
|
||||||
hardware.graphics = {
|
hardware.graphics = {
|
||||||
nvidia = false; #FIXME: Compile error
|
nvidia = false; #FIXME: Compile error
|
||||||
intel = true;
|
intel = true;
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
neovim = false;
|
neovim = false;
|
||||||
server = false;
|
# server = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#NOTE: Old info
|
#NOTE: Old info
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1,16 +0,0 @@
|
||||||
age-encryption.org/v1
|
|
||||||
-> ssh-ed25519 GQzYWA a0CqbXhMIeFmKsMSnQzPWJcdi0hH8caayThGHtKNdjc
|
|
||||||
ZfRN0ukqXH8L1E1pWBU+tw0LmPxsb6/4FoeERCKEYCk
|
|
||||||
-> ssh-ed25519 MfR7VA WO0CmKh4CQY1ZLtgDbGIhxfbC8C/C9Vw4p4UGkZTzSs
|
|
||||||
0oQbzzz8A6WJRbFqEPR6WStMRRGtFy2eEXIJ1WCqvIg
|
|
||||||
-> ssh-ed25519 +cvRTg ZYBJwTDV8zwZIpqY7sZIszS3saww0OV4RwVREVNxWHg
|
|
||||||
PW9gzG2odI4G2I5zz+Gr2vaouPB6796RWDJzYZNFREQ
|
|
||||||
-> ssh-ed25519 WCPLrA p8I1d6YXg5pN6Ljeq/wsY5jj4rPaSvD+/au+vEUsgh4
|
|
||||||
U0aiqeildEqF8SNh0L4hGIq3rQxY4HcSnDvluwldDpQ
|
|
||||||
-> ssh-ed25519 7/ziYw 7DGE8Zr0qMGh3P5lUSRYT+AdgRges037cLjHbbPPnTc
|
|
||||||
daC7dau5IHSZr/HmjszbWrQNsVJOQILqNS/Yn1YE/zM
|
|
||||||
-> ssh-ed25519 VQy60Q cAuS4VLmDC9iCZ+7e+/5WVIxrvBa7ZChCz2pPSSY/TY
|
|
||||||
ut6SAJSZMm9/YElx7SShyMufrBYAlb/IyQp0g4ADMa4
|
|
||||||
--- DQrDZ/cXaadnKTDN8MrGuTokHttdMbOzs2IPYTIOPw4
|
|
||||||
Ôú9èçEJG($Ç'_±z·3õ<33>§!;\Ûkç<6B><C3A7>IâEæ3„%”!zŒíÄþO£‚ôŠú«*’®ÂÂãÝ.,ó à•…`û+',À*ÝÞÄÑml%g?â¥0°'ñ-<MíwYŒj]SR‡aÕ©V–£Í(çk”—yü6Â@`j9jÈ~¨[úò_º½Dz±¨Ìd^¨"\Ú7ÍóéÔîlóÂþO#ǃÏcW=ô‚a~K],0![ßG¨~4ª™!XÅ›Ê|ÿó·(CÌ4)g^-¢5D”n¶lI·m C§,ê-9ƒš4¢åÓbI:– 1áõÝUx»ôe¡ôMÄêã’¡X(¯ÿʼ5²m킌[ÖBXHãâ f_ä‹J{Ôuóf<C3B3>OT”D^¸*Y3³-<2D>ƒ•³ƒŠ¹e-OB¤t
Á‘.Qaሲ{m¼ð$W7ÝL>r¿Â•'‰>€b6º¹D©;w*.uYž‡µ°÷ÃXß`A**Œ2¨$T<>ïtÔŒM<C592>Â_1NÜÆ‹dã
|
|
||||||
<06>@cJsÎåtÄ,Ð…hÏïaº¯ÇJŠ<4A>pØå§j:æ¼sG@P/¼¾LœÜ4˜¥ö>XRÞ{f¶íJB>ƒ–Ãzï&÷ÖÀ;|’‚û«v‹œÎçΚJ<C5A1>ÙS•¥Úì±Î¶AÄ,7ÉE{MEõwí<77>PªÉ:ÿG‰òcœŠYžR¯ç³³ z£@³Xô„æÕ<C3A6>*½j%MM•ĵšB¦´`HzŸéÝSëKUWy+xûGÇDåÈ“¯Ém÷ï~›¬Ö›êóÉû¹‰·>ó%Î]RƒŸ;9”–¶¿8åœV…¾ÉL›c (<28>RÌXäRùrŽl˜!eSAʧG3jhw¼œ•˜ƒ»£ª›Ò,ã2b1
|
|
||||||
|
|
@ -14,35 +14,35 @@ in {
|
||||||
password.file = ./password.age;
|
password.file = ./password.age;
|
||||||
|
|
||||||
# NOTE: server things
|
# NOTE: server things
|
||||||
dcbot = mkIf server {
|
jsw-bot = mkIf server.jsw-bot.enable {
|
||||||
file = ./dcbot.age;
|
file = ./jsw-bot.age;
|
||||||
owner = serviceUser "dcbot"; #
|
owner = serviceUser "jsw-bot"; #
|
||||||
};
|
};
|
||||||
bread-dcbot = mkIf server {
|
derek-bot = mkIf server.derek-bot.enable {
|
||||||
file = ./bread-dcbot.age;
|
file = ./derek-bot.age;
|
||||||
owner = "bread-dcbot";
|
owner = "derek-bot";
|
||||||
};
|
};
|
||||||
matrix-registration = mkIf server {
|
# matrix-registration = mkIf server.matrix.enable {
|
||||||
file = ./matrix-registration.age;
|
# file = ./matrix-registration.age;
|
||||||
owner = abstrServiceUser "matrix-continuwuity";
|
# owner = abstrServiceUser "matrix-continuwuity";
|
||||||
};
|
# };
|
||||||
mail-admin = mkIf server {
|
mail-admin = mkIf server.stalwart.enable {
|
||||||
# owner = serviceUser "stalwart-mail"; #FIXME: revert when stopped using docker for stalwart.
|
# owner = serviceUser "stalwart-mail"; #FIXME: revert when stopped using docker for stalwart.
|
||||||
file = ./mail-admin.age;
|
file = ./mail-admin.age;
|
||||||
};
|
};
|
||||||
zitadel-key = mkIf server {
|
zitadel-key = mkIf server.zitadel.enable {
|
||||||
file = ./zitadel-key.age;
|
file = ./zitadel-key.age;
|
||||||
owner = abstrServiceUser "zitadel";
|
owner = abstrServiceUser "zitadel";
|
||||||
};
|
};
|
||||||
forgejo-mailpass = mkIf server {
|
forgejo-mailpass = mkIf server.forgejo.enable {
|
||||||
file = ./forgejo-mailpass.age;
|
file = ./forgejo-mailpass.age;
|
||||||
owner = abstrServiceUser "forgejo";
|
owner = abstrServiceUser "forgejo";
|
||||||
};
|
};
|
||||||
immich-oidc = mkIf server {
|
immich-oidc = mkIf server.immich.enable {
|
||||||
file = ./immich-oidc.age;
|
file = ./immich-oidc.age;
|
||||||
owner = abstrServiceUser "immich";
|
owner = abstrServiceUser "immich";
|
||||||
};
|
};
|
||||||
nextcloud-admin-pass = mkIf server {
|
nextcloud-admin-pass = mkIf server.nextcloud.enable {
|
||||||
file = ./nextcloud-admin-pass.age;
|
file = ./nextcloud-admin-pass.age;
|
||||||
owner = "nextcloud"; #NOTE: not a clear 'nextcloud.service' or 'services.nextcloud.user'.
|
owner = "nextcloud"; #NOTE: not a clear 'nextcloud.service' or 'services.nextcloud.user'.
|
||||||
};
|
};
|
||||||
|
|
|
||||||
BIN
secrets/derek-bot.age
Normal file
BIN
secrets/derek-bot.age
Normal file
Binary file not shown.
BIN
secrets/jsw-bot.age
Normal file
BIN
secrets/jsw-bot.age
Normal file
Binary file not shown.
|
|
@ -14,8 +14,8 @@ let
|
||||||
keys = users ++ devices;
|
keys = users ++ devices;
|
||||||
in {
|
in {
|
||||||
"password.age".publicKeys = keys;
|
"password.age".publicKeys = keys;
|
||||||
"dcbot.age".publicKeys = keys;
|
"jsw-bot.age".publicKeys = keys;
|
||||||
"bread-dcbot.age".publicKeys = keys;
|
"derek-bot.age".publicKeys = keys;
|
||||||
"matrix-registration.age".publicKeys = keys;
|
"matrix-registration.age".publicKeys = keys;
|
||||||
"mail-admin.age".publicKeys = keys;
|
"mail-admin.age".publicKeys = keys;
|
||||||
"zitadel-key.age".publicKeys = keys;
|
"zitadel-key.age".publicKeys = keys;
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,15 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
cfg = config.niksos.server;
|
inherit (config.services.caddy) enable;
|
||||||
|
inherit (lib) mkIf;
|
||||||
in {
|
in {
|
||||||
|
config = mkIf enable {
|
||||||
services.caddy = {
|
services.caddy = {
|
||||||
enable = cfg;
|
|
||||||
email = "jurnwubben@gmail.com";
|
email = "jurnwubben@gmail.com";
|
||||||
enableReload = false;
|
enableReload = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = lib.mkIf cfg [80 443];
|
networking.firewall.allowedTCPPorts = [80 443];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,24 @@
|
||||||
{lib, ...}: {
|
{lib, ...}: let
|
||||||
|
inherit (lib) mkOption types;
|
||||||
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
# ./matrix.nix
|
# ./matrix.nix
|
||||||
./bot.nix
|
# ./temp.nix
|
||||||
|
./jsw-bot.nix
|
||||||
./caddy.nix
|
./caddy.nix
|
||||||
./derekBot.nix
|
./derek-bot.nix
|
||||||
./forgejo.nix
|
./forgejo.nix
|
||||||
./immich.nix
|
./immich.nix
|
||||||
./index
|
./index
|
||||||
./mail.nix
|
./mail.nix
|
||||||
./nextcloud.nix
|
./nextcloud.nix
|
||||||
./temp.nix
|
|
||||||
./zitadel.nix
|
./zitadel.nix
|
||||||
];
|
];
|
||||||
options.niksos.server = lib.mkEnableOption "server servcies (such as caddy)."; #TODO: per service option.
|
options.niksos.server = {
|
||||||
|
baseDomain = mkOption {
|
||||||
|
type = types.lines;
|
||||||
|
description = "Set's the apex domain for the webservices. Do not include 'https' or a slash at the end. Just 'example.com'.";
|
||||||
|
example = "example.com";
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,26 +4,26 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
cfg = config.niksos.server;
|
name = "derek-bot";
|
||||||
userGroup = "bread-dcbot";
|
cfg = config.niksos.server.${name}.enable;
|
||||||
|
|
||||||
|
userGroup = name;
|
||||||
gitRepo = "https://github.com/The-Breadening/Breadener";
|
gitRepo = "https://github.com/The-Breadening/Breadener";
|
||||||
|
|
||||||
bash = lib.getExe pkgs.bash;
|
inherit (lib) getExe mkEnableOption mkIf;
|
||||||
|
bash = getExe pkgs.bash;
|
||||||
|
|
||||||
varLib = "/var/lib/";
|
varLib = "/var/lib/";
|
||||||
mainDir =
|
mainDir = "${varLib}${userGroup}";
|
||||||
varLib
|
programDir = "${mainDir}/program";
|
||||||
+ (
|
denoDir = "${mainDir}/deno";
|
||||||
if !cfg
|
tokenDir = "${mainDir}/Breadener-token";
|
||||||
then ""
|
|
||||||
else userGroup
|
|
||||||
)
|
|
||||||
+ "/";
|
|
||||||
programDir = mainDir + "program";
|
|
||||||
denoDir = mainDir + "deno";
|
|
||||||
tokenDir = mainDir + "Breadener-token";
|
|
||||||
path = builtins.concatStringsSep ":" (map (x: "${x}/bin/") [pkgs.coreutils pkgs.deno pkgs.git]);
|
path = builtins.concatStringsSep ":" (map (x: "${x}/bin/") [pkgs.coreutils pkgs.deno pkgs.git]);
|
||||||
in {
|
in {
|
||||||
config = lib.mkIf config.niksos.server {
|
options.niksos.server.${name}.enable = mkEnableOption name;
|
||||||
|
|
||||||
|
config = mkIf cfg {
|
||||||
systemd.services.${userGroup} = {
|
systemd.services.${userGroup} = {
|
||||||
enable = true;
|
enable = true;
|
||||||
after = ["network.target"];
|
after = ["network.target"];
|
||||||
|
|
@ -39,7 +39,7 @@ in {
|
||||||
export PATH=${path}
|
export PATH=${path}
|
||||||
|
|
||||||
cd "${mainDir}"
|
cd "${mainDir}"
|
||||||
chown -R ${userGroup}:${userGroup} ${mainDir}* || echo
|
chown -R ${userGroup}:${userGroup} ${mainDir}/* || echo
|
||||||
|
|
||||||
rm -rf "${tokenDir}" || echo
|
rm -rf "${tokenDir}" || echo
|
||||||
mkdir -p "${denoDir}" "${tokenDir}"
|
mkdir -p "${denoDir}" "${tokenDir}"
|
||||||
|
|
@ -48,7 +48,7 @@ in {
|
||||||
if [ ! -d "${programDir}" ]; then
|
if [ ! -d "${programDir}" ]; then
|
||||||
git clone "${gitRepo}" "${programDir}"
|
git clone "${gitRepo}" "${programDir}"
|
||||||
fi
|
fi
|
||||||
chmod -R 750 ${mainDir}* || echo
|
chmod -R 750 ${mainDir}/* || echo
|
||||||
|
|
||||||
|
|
||||||
cd "${programDir}"
|
cd "${programDir}"
|
||||||
|
|
@ -3,17 +3,24 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
DOMAIN = "git.jsw.tf";
|
name = "forgejo";
|
||||||
|
cfg = import ./lib/extractWebOptions.nix {inherit config name;};
|
||||||
|
|
||||||
|
DOMAIN = cfg.domain;
|
||||||
in {
|
in {
|
||||||
|
options = import ./lib/webOptions.nix {inherit config lib name;};
|
||||||
config =
|
config =
|
||||||
lib.mkIf config.niksos.server
|
lib.mkIf cfg.enable
|
||||||
{
|
{
|
||||||
services.caddy.virtualHosts.${DOMAIN}.extraConfig = ''
|
services.caddy = {
|
||||||
|
enable = true;
|
||||||
|
virtualHosts.${DOMAIN}.extraConfig = ''
|
||||||
request_body {
|
request_body {
|
||||||
max_size 512M
|
max_size 512M
|
||||||
}
|
}
|
||||||
reverse_proxy unix/${config.services.forgejo.settings.server.HTTP_ADDR}
|
reverse_proxy unix/${config.services.forgejo.settings.server.HTTP_ADDR}
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
services.forgejo = {
|
services.forgejo = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
@ -52,12 +59,13 @@ in {
|
||||||
DEFAULT_ACTIONS_URL = "github";
|
DEFAULT_ACTIONS_URL = "github";
|
||||||
};
|
};
|
||||||
mailer = {
|
mailer = {
|
||||||
|
#FIXME: Only enable if stalwart is enabled by default.
|
||||||
ENABLED = true;
|
ENABLED = true;
|
||||||
SUBJECT_PREFIX = "JSWGit";
|
SUBJECT_PREFIX = "JSWGit";
|
||||||
PROTOCOL = "smtps";
|
PROTOCOL = "smtps";
|
||||||
SMTP_ADDR = "mail.jsw.tf"; #FIXME: replace with config... to stalwart setting once using stalwart nixos module.
|
SMTP_ADDR = "mail.${cfg.baseDomain}"; #FIXME: replace with config... to stalwart setting once using stalwart nixos module.
|
||||||
SMTP_PORT = 465;
|
SMTP_PORT = 465;
|
||||||
FROM = "git@jsw.tf";
|
FROM = "git@${cfg.baseDomain}";
|
||||||
USER = "git";
|
USER = "git";
|
||||||
PASSWD_URI = "file:${config.age.secrets.forgejo-mailpass.path}";
|
PASSWD_URI = "file:${config.age.secrets.forgejo-mailpass.path}";
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,23 +4,29 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
|
name = "immich";
|
||||||
inherit (lib) mkIf mkForce mkDefault;
|
inherit (lib) mkIf mkForce mkDefault;
|
||||||
|
|
||||||
cfg = config.niksos.server;
|
cfg = import ./lib/extractWebOptions.nix {inherit config name;};
|
||||||
|
|
||||||
oidcSubstitute = "*@#OPENIDCLIENTSECRET#@*";
|
oidcSubstitute = "*@#OPENIDCLIENTSECRET#@*";
|
||||||
config-dir = "/run/immich-conf";
|
config-dir = "/run/immich-conf";
|
||||||
url = "photos.jsw.tf";
|
httpsUrl = "https://" + cfg.domain;
|
||||||
httpsUrl = "https://" + url;
|
|
||||||
in {
|
in {
|
||||||
|
options = import ./lib/webOptions.nix {inherit config lib name;};
|
||||||
|
|
||||||
config =
|
config =
|
||||||
mkIf cfg
|
mkIf cfg.enable
|
||||||
{
|
{
|
||||||
users.users.${config.services.immich.user}.extraGroups = ["video" "render"];
|
services.caddy = {
|
||||||
services.caddy.virtualHosts.${url}.extraConfig = ''
|
enable = true;
|
||||||
|
virtualHosts.${cfg.domain}.extraConfig = ''
|
||||||
reverse_proxy localhost:9002
|
reverse_proxy localhost:9002
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
services.immich = mkIf cfg {
|
users.users.${config.services.immich.user}.extraGroups = ["video" "render"];
|
||||||
|
services.immich = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
port = 9002;
|
port = 9002;
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,13 @@
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: {
|
}: let
|
||||||
services.caddy.virtualHosts."jsw.tf" = lib.mkIf config.niksos.server {
|
name = "site";
|
||||||
|
cfg = import ../lib/extractWebOptions.nix {inherit config name;};
|
||||||
|
in {
|
||||||
|
options = import ../lib/webOptions.nix {inherit config lib name;};
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
services.caddy.virtualHosts.${cfg.domain} = {
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
header Content-Type text/html
|
header Content-Type text/html
|
||||||
respond <<HTML
|
respond <<HTML
|
||||||
|
|
@ -11,4 +16,5 @@
|
||||||
HTML 200
|
HTML 200
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,13 @@
|
||||||
inputs,
|
inputs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
deno = lib.getExe pkgs.deno;
|
name = "jsw-bot";
|
||||||
bash = lib.getExe pkgs.bash;
|
cfg = import ./lib/extractWebOptions.nix {inherit config name;};
|
||||||
|
|
||||||
|
inherit (lib) getExe mkIf optional;
|
||||||
|
inherit (config.niksos.server) nextcloud;
|
||||||
|
|
||||||
|
bash = getExe pkgs.bash;
|
||||||
|
|
||||||
mainDir = "/var/lib/dcbot/";
|
mainDir = "/var/lib/dcbot/";
|
||||||
programDir = mainDir + "program";
|
programDir = mainDir + "program";
|
||||||
|
|
@ -15,10 +20,14 @@
|
||||||
|
|
||||||
path = builtins.concatStringsSep ":" (map (x: "${x}/bin/") [pkgs.coreutils pkgs.typst pkgs.deno]);
|
path = builtins.concatStringsSep ":" (map (x: "${x}/bin/") [pkgs.coreutils pkgs.typst pkgs.deno]);
|
||||||
in {
|
in {
|
||||||
config = lib.mkIf config.niksos.server {
|
options = import ./lib/webOptions.nix {
|
||||||
systemd.services.dcbot = {
|
inherit config lib name;
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
systemd.services.${name} = {
|
||||||
enable = true;
|
enable = true;
|
||||||
after = ["network.target"];
|
after = ["network.target"]; #FIXME: doesn't start after network.
|
||||||
wantedBy = ["default.target"];
|
wantedBy = ["default.target"];
|
||||||
description = "Jsw's slaafje, discord bot.";
|
description = "Jsw's slaafje, discord bot.";
|
||||||
|
|
||||||
|
|
@ -33,35 +42,37 @@ in {
|
||||||
cd "${mainDir}"
|
cd "${mainDir}"
|
||||||
mkdir -p "${programDir}" "${dataDir}" "${denoDir}"
|
mkdir -p "${programDir}" "${dataDir}" "${denoDir}"
|
||||||
|
|
||||||
chown -R dcbot:dcbot ${mainDir}* || echo
|
chown -R ${name}:${name} ${mainDir}* || echo
|
||||||
chmod -R 750 ${mainDir}* || echo
|
chmod -R 750 ${mainDir}* || echo
|
||||||
cp --no-preserve=mode,ownership -r ${inputs.dcbot}/* "${programDir}/"
|
cp --no-preserve=mode,ownership -r ${inputs.dcbot}/* "${programDir}/"
|
||||||
|
|
||||||
rm "${dataDir}/.env" || echo
|
rm "${dataDir}/.env" || echo
|
||||||
ln -s "${config.age.secrets.dcbot.path}" "${dataDir}/.env"
|
ln -s "${config.age.secrets.jsw-bot.path}" "${dataDir}/.env"
|
||||||
|
|
||||||
cd "${programDir}"
|
cd "${programDir}"
|
||||||
DENO_DIR=${denoDir} deno i
|
DENO_DIR=${denoDir} deno i
|
||||||
'';
|
'';
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
StateDirectory = "dcbot";
|
StateDirectory = name;
|
||||||
ExecStart = "${bash} -c 'cd ${dataDir} && deno run -A ${programDir}/src/main.ts'";
|
ExecStart = "${bash} -c 'cd ${dataDir} && deno run -A ${programDir}/src/main.ts'";
|
||||||
User = "dcbot";
|
User = name;
|
||||||
Group = "dcbot";
|
Group = name;
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.caddy.virtualHosts."dc.jsw.tf" = {
|
services.caddy = {
|
||||||
serverAliases = ["www.dc.jsw.tf"];
|
enable = true;
|
||||||
|
virtualHosts.${cfg.domain} = {
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
reverse_proxy :9001
|
reverse_proxy :9001
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
users.groups."dcbot" = {
|
users.groups."dcbot" = {
|
||||||
members = ["nextcloud"]; #TODO: if config.niksos.server.nextcloud
|
members = optional nextcloud.enable "nextcloud"; #TODO: if config.niksos.server.nextcloud
|
||||||
#NOTE: for nextcloud mounted folder
|
#NOTE: for nextcloud mounted folder
|
||||||
};
|
};
|
||||||
users.users."dcbot" = {
|
users.users."dcbot" = {
|
||||||
18
system/server/lib/extractWebOptions.nix
Normal file
18
system/server/lib/extractWebOptions.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
name,
|
||||||
|
}: let
|
||||||
|
inherit (config.niksos) server;
|
||||||
|
inherit (server) baseDomain;
|
||||||
|
cfg = server.${name};
|
||||||
|
|
||||||
|
subDomain =
|
||||||
|
if cfg.subDomain == ""
|
||||||
|
then ""
|
||||||
|
else "${cfg.subDomain}.";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
domain = "${subDomain}.${baseDomain}";
|
||||||
|
inherit baseDomain;
|
||||||
|
}
|
||||||
|
// cfg
|
||||||
16
system/server/lib/webOptions.nix
Normal file
16
system/server/lib/webOptions.nix
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
name,
|
||||||
|
}: let
|
||||||
|
inherit (lib) mkEnableOption mkOption types;
|
||||||
|
in {
|
||||||
|
niksos.server.${name} = {
|
||||||
|
enable = mkEnableOption name;
|
||||||
|
subDomain = mkOption {
|
||||||
|
type = types.lines;
|
||||||
|
description = "What subdomain to use for ${name}";
|
||||||
|
example = name;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -2,10 +2,15 @@
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: {
|
}: let
|
||||||
|
name = "stalwart";
|
||||||
|
cfg = import ./lib/extractWebOptions.nix {inherit config name;};
|
||||||
|
in {
|
||||||
#FIXME: revert when stopped using docker for stalwart. https://github.com/NixOS/nixpkgs/issues/416091 (look at older commits for previous code.)
|
#FIXME: revert when stopped using docker for stalwart. https://github.com/NixOS/nixpkgs/issues/416091 (look at older commits for previous code.)
|
||||||
|
|
||||||
config = lib.mkIf config.niksos.server {
|
options = import ./lib/webOptions.nix {inherit lib config name;};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
virtualisation.oci-containers.containers.stalwart = {
|
virtualisation.oci-containers.containers.stalwart = {
|
||||||
image = "docker.io/stalwartlabs/stalwart:latest";
|
image = "docker.io/stalwartlabs/stalwart:latest";
|
||||||
labels = {
|
labels = {
|
||||||
|
|
@ -22,8 +27,11 @@
|
||||||
465
|
465
|
||||||
];
|
];
|
||||||
|
|
||||||
services.caddy.virtualHosts."mail.jsw.tf".extraConfig = ''
|
services.caddy = {
|
||||||
|
enable = true;
|
||||||
|
virtualHosts.${cfg.domain}.extraConfig = ''
|
||||||
reverse_proxy http://127.0.0.1:9003
|
reverse_proxy http://127.0.0.1:9003
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,37 +3,38 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
database = {
|
name = "matrix";
|
||||||
connection_string = "postgres:///dendrite?host=/run/postgresql";
|
cfg = import ./lib/extractWebOptions.nix {inherit config name;};
|
||||||
max_open_conns = 97;
|
|
||||||
max_idle_conns = 5;
|
|
||||||
conn_max_lifetime = -1;
|
|
||||||
};
|
|
||||||
host = "matrix.jsw.tf";
|
|
||||||
in {
|
in {
|
||||||
config = lib.mkIf config.niksos.server {
|
options = import ./lib/webOptions.nix {inherit config lib name;};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
services = {
|
services = {
|
||||||
matrix-continuwuity = {
|
matrix-continuwuity = {
|
||||||
enable = true;
|
enable = true;
|
||||||
group = "caddy"; # Permissions for socket
|
group = "caddy"; # Permissions for socket
|
||||||
|
#FIXME: caddy should be part of matrix group, not other way around
|
||||||
settings.global = {
|
settings.global = {
|
||||||
unix_socket_path = "/run/continuwuity/continuwuity.sock";
|
unix_socket_path = "/run/continuwuity/continuwuity.sock";
|
||||||
server_name = host;
|
server_name = cfg.domain;
|
||||||
allow_registration = true;
|
allow_registration = true;
|
||||||
registration_token_file = config.age.secrets.matrix-registration.path;
|
registration_token_file = config.age.secrets.matrix-registration.path;
|
||||||
new_user_displayname_suffix = "";
|
new_user_displayname_suffix = "";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
caddy.virtualHosts = {
|
caddy = {
|
||||||
${host}.extraConfig = ''
|
enable = true;
|
||||||
|
virtualHosts = {
|
||||||
|
${cfg.domain}.extraConfig = ''
|
||||||
header /.well-known/matrix/* Content-Type application/json
|
header /.well-known/matrix/* Content-Type application/json
|
||||||
header /.well-known/matrix/* Access-Control-Allow-Origin *
|
header /.well-known/matrix/* Access-Control-Allow-Origin *
|
||||||
respond /.well-known/matrix/server `{"m.server": "${host}:443"}`
|
respond /.well-known/matrix/server `{"m.server": "${cfg.domain}:443"}`
|
||||||
respond /.well-known/matrix/client `{"m.homeserver": {"base_url": "https://${host}"}}`
|
respond /.well-known/matrix/client `{"m.homeserver": {"base_url": "https://${cfg.domain}"}}`
|
||||||
reverse_proxy /_matrix/* unix//run/continuwuity/continuwuity.sock
|
reverse_proxy /_matrix/* unix//run/continuwuity/continuwuity.sock
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,18 +4,24 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (config.niksos) server;
|
name = "nextcloud";
|
||||||
host = "cloud.jsw.tf";
|
cfg = import ./lib/extractWebOptions.nix {inherit config name;};
|
||||||
nginxRoot = config.services.nginx.virtualHosts.${host}.root;
|
|
||||||
|
inherit (cfg) enable domain;
|
||||||
|
|
||||||
|
nginxRoot = config.services.nginx.virtualHosts.${domain}.root;
|
||||||
fpmSocket = config.services.phpfpm.pools.nextcloud.socket;
|
fpmSocket = config.services.phpfpm.pools.nextcloud.socket;
|
||||||
imaginaryPort = 9004;
|
imaginaryPort = 9004;
|
||||||
in {
|
in {
|
||||||
config = lib.mkIf server {
|
options = import ./lib/webOptions.nix {inherit config lib name;};
|
||||||
|
|
||||||
|
config = lib.mkIf enable {
|
||||||
users.groups.nextcloud.members = ["nextcloud" "caddy"];
|
users.groups.nextcloud.members = ["nextcloud" "caddy"];
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
nextcloud = {
|
nextcloud = {
|
||||||
enable = true;
|
enable = true;
|
||||||
hostName = host;
|
hostName = domain;
|
||||||
|
|
||||||
# Need to manually increment with every major upgrade.
|
# Need to manually increment with every major upgrade.
|
||||||
package = pkgs.nextcloud31;
|
package = pkgs.nextcloud31;
|
||||||
|
|
@ -77,12 +83,12 @@ in {
|
||||||
dbtype = "pgsql";
|
dbtype = "pgsql";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
imaginary = {
|
# imaginary = { #FIXME: doesn't start.
|
||||||
enable = true;
|
# enable = true;
|
||||||
port = imaginaryPort;
|
# port = imaginaryPort;
|
||||||
address = "localhost";
|
# address = "localhost";
|
||||||
settings.returnSize = true;
|
# settings.returnSize = true;
|
||||||
};
|
# };
|
||||||
|
|
||||||
nginx.enable = lib.mkForce false;
|
nginx.enable = lib.mkForce false;
|
||||||
phpfpm.pools.nextcloud.settings = let
|
phpfpm.pools.nextcloud.settings = let
|
||||||
|
|
@ -91,7 +97,10 @@ in {
|
||||||
"listen.owner" = user;
|
"listen.owner" = user;
|
||||||
"listen.group" = group;
|
"listen.group" = group;
|
||||||
};
|
};
|
||||||
caddy.virtualHosts."${host}".extraConfig = ''
|
|
||||||
|
caddy = {
|
||||||
|
enable = true;
|
||||||
|
virtualHosts.${domain}.extraConfig = ''
|
||||||
encode zstd gzip
|
encode zstd gzip
|
||||||
|
|
||||||
root * ${nginxRoot}
|
root * ${nginxRoot}
|
||||||
|
|
@ -145,4 +154,5 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
|
#WARNING: deprecated
|
||||||
{
|
{
|
||||||
config,
|
# config,
|
||||||
pkgs,
|
# pkgs,
|
||||||
lib,
|
# lib,
|
||||||
inputs,
|
# inputs,
|
||||||
...
|
# ...
|
||||||
}: {
|
# }: {
|
||||||
config = lib.mkIf config.niksos.server {
|
# config = lib.mkIf config.niksos.server {
|
||||||
# NOTE: allows me to spin up temporarily services.
|
# # NOTE: allows me to spin up temporarily services.
|
||||||
services.caddy.virtualHosts."temp.jsw.tf".extraConfig = ''
|
# services.caddy.virtualHosts."temp.jsw.tf".extraConfig = ''
|
||||||
reverse_proxy :8000
|
# reverse_proxy :8000
|
||||||
'';
|
# '';
|
||||||
};
|
# };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,22 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
ExternalDomain = "z.jsw.tf";
|
name = "zitadel";
|
||||||
|
cfg = import ./lib/extractWebOptions.nix {inherit config name;};
|
||||||
|
|
||||||
Port = 9000;
|
Port = 9000;
|
||||||
in {
|
in {
|
||||||
|
options = import ./lib/webOptions.nix {inherit config lib name;};
|
||||||
|
|
||||||
config =
|
config =
|
||||||
lib.mkIf config.niksos.server
|
lib.mkIf cfg.enable
|
||||||
{
|
{
|
||||||
services.caddy.virtualHosts.${ExternalDomain}.extraConfig = ''
|
services.caddy = {
|
||||||
|
enable = true;
|
||||||
|
virtualHosts.${cfg.domain}.extraConfig = ''
|
||||||
reverse_proxy localhost:${builtins.toString Port}
|
reverse_proxy localhost:${builtins.toString Port}
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
# services.zitadel = {
|
# services.zitadel = {
|
||||||
# enable = true;
|
# enable = true;
|
||||||
|
|
@ -32,8 +39,10 @@ in {
|
||||||
enable = true;
|
enable = true;
|
||||||
masterKeyFile = config.age.secrets.zitadel-key.path;
|
masterKeyFile = config.age.secrets.zitadel-key.path;
|
||||||
settings = {
|
settings = {
|
||||||
inherit Port ExternalDomain;
|
inherit Port;
|
||||||
|
ExternalDomain = cfg.domain;
|
||||||
ExternalPort = 443;
|
ExternalPort = 443;
|
||||||
|
|
||||||
Database.postgres = {
|
Database.postgres = {
|
||||||
Host = "/var/run/postgresql/";
|
Host = "/var/run/postgresql/";
|
||||||
Port = 5432;
|
Port = 5432;
|
||||||
|
|
@ -53,9 +62,9 @@ in {
|
||||||
steps.FirstInstance = {
|
steps.FirstInstance = {
|
||||||
InstanceName = "jsw";
|
InstanceName = "jsw";
|
||||||
Org = {
|
Org = {
|
||||||
Name = "jsw";
|
Name = "jsw-admin";
|
||||||
Human = {
|
Human = {
|
||||||
UserName = "jsw@jsw.tf";
|
UserName = "jsw-admin@jsw.tf";
|
||||||
FirstName = "Jurn";
|
FirstName = "Jurn";
|
||||||
LastName = "Wubben";
|
LastName = "Wubben";
|
||||||
Email.Verified = true;
|
Email.Verified = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue