refactor: complete overhaul

This commit is contained in:
Nick 2024-11-10 01:29:37 -06:00
parent fb3e6fed86
commit 0541b3d61f
154 changed files with 936 additions and 904 deletions

View file

@ -24,6 +24,7 @@ in let
userSubmodule = lib.types.submodule {
options = {
name = stringType;
label = stringType;
sshKeys = listType;
group = stringType;
aliases = genOptions stringType "name";
@ -154,8 +155,8 @@ in {
};
config = {
people = import ./users.nix;
services = import ./instances.nix;
machines = import ./devices.nix;
people = import ./users;
services = import ./instances;
machines = import ./devices;
};
}

View file

@ -1,147 +0,0 @@
let
ownerWriteOthersReadMask = ["fmask=0022" "dmask=0022"];
ownerExclusiveReadWriteMask = ["fmask=0077" "dmask=0077"];
readWritePermissions = ["rw"];
sambaPermissions = ["rw" "gid=100" "vers=3.0" "x-systemd.automount" "x-systemd.requires=network-online.target"];
fileModeAndDirMode = ["file_mode=0644" "dir_mode=0755"];
userIdForUser0 = ["uid=1000"];
userIdForUser1 = ["uid=1001"];
in {
devices = {
# Desktop
desktop = {
label = "Desktop";
name = "desktop";
sync = "";
ip = {
address0 = "192.168.50.196";
};
boot = {
options = ownerWriteOthersReadMask;
};
storage0 = {
mount = "/mnt/media/games";
device = "/dev/disk/by-label/Games";
options = readWritePermissions;
};
storage1 = {
mount = "/mnt/media/storage";
device = "/dev/disk/by-label/Storage";
options = readWritePermissions;
};
};
# Laptop
laptop = {
label = "Laptop";
name = "laptop";
sync = "";
ip = {
address0 = "192.168.50.142";
};
boot = {
options = ownerWriteOthersReadMask;
};
};
# Server
server = let
serverName = "server";
serverIP = "192.168.50.140";
serverStorageDriveName = "NAS1";
in {
label = "Server";
name = serverName;
ip = {
address0 = serverIP;
};
boot = {
options = ownerExclusiveReadWriteMask;
};
storage0 = {
mount = "/mnt/media/${serverStorageDriveName}";
device = "/dev/disk/by-label/${serverStorageDriveName}";
options = readWritePermissions;
};
samba0 = {
mount = "/mnt/media/${serverName}";
device = "//${serverIP}";
options = sambaPermissions ++ fileModeAndDirMode ++ userIdForUser0;
};
};
# Synology
nas = let
user0 = "nick";
user1 = "garnet";
user0Name = "Nick";
user1Name = "Garnet";
nasName = "synology";
nasIP = "192.168.50.209";
in {
label = "Synology";
sync = "MWRGX2V-F5XKE5E-REP6ECT-OOPFBMF-22NHSMW-YFBU6MB-PLFUN63-R3MW2QX";
name = nasName;
ip = {
address0 = nasIP;
};
# Nick Home Folder
folder0 = {
mount = "/mnt/media/${nasName}/${user0}";
device = "//${nasIP}/homes/${user0Name}";
options = sambaPermissions ++ userIdForUser0;
};
# Garnet Home Folder
folder1 = {
mount = "/mnt/media/${nasName}/${user1}";
device = "//${nasIP}/homes/${user1Name}";
options = sambaPermissions ++ userIdForUser1;
};
# Minecraft Worlds
folder2 = {
mount = "/home/${user1}/.local/share/PrismLauncher/instances/1.21/.minecraft/saves";
device = "//${nasIP}/homes/${user1Name}/Minecraft";
options = sambaPermissions ++ userIdForUser1;
};
};
# Pixel 9
phone = {
name = "pixel";
sync = "RMDKNJY-BTX6FYF-G6SR332-WS6HARI-PF74SC6-VPBSGRQ-MKVQZEQ-KSIB6QV";
ip = {
address0 = "192.168.50.243";
};
};
# Printer
printer0 = {
label = "Canon-TR7620a";
ip = {
address0 = "";
};
};
printer1 = {
label = "Brother-HL-2170W";
ip = {
address0 = "192.168.50.195";
};
};
# Samsung S7 FE
tablet = {
name = "tablet";
sync = "I2ZSCZU-T4JMUJJ-XCUQ3MY-G5EUFZ5-KRG2DRY-XIBJZZM-FQW3UMY-CBCTUQU";
ip = {
address0 = "192.168.50.189";
};
};
};
}

View file

@ -0,0 +1,27 @@
{devicesFunctions}: let
inherit
(devicesFunctions)
ownerWriteOthersReadMask
readWritePermissions
;
in {
label = "Desktop";
name = "desktop";
sync = "";
ip = {
address0 = "192.168.50.196";
};
boot = {
options = ownerWriteOthersReadMask;
};
storage0 = {
mount = "/mnt/media/games";
device = "/dev/disk/by-label/Games";
options = readWritePermissions;
};
storage1 = {
mount = "/mnt/media/storage";
device = "/dev/disk/by-label/Storage";
options = readWritePermissions;
};
}

View file

@ -0,0 +1,16 @@
{devicesFunctions}: let
inherit
(devicesFunctions)
ownerWriteOthersReadMask
;
in {
label = "Laptop";
name = "laptop";
sync = "";
ip = {
address0 = "192.168.50.142";
};
boot = {
options = ownerWriteOthersReadMask;
};
}

View file

@ -0,0 +1,13 @@
{devicesFunctions}: let
inherit
(devicesFunctions)
dummy
;
in {
name = "pixel";
label = dummy;
sync = "RMDKNJY-BTX6FYF-G6SR332-WS6HARI-PF74SC6-VPBSGRQ-MKVQZEQ-KSIB6QV";
ip = {
address0 = "192.168.50.243";
};
}

View file

@ -0,0 +1,12 @@
{devicesFunctions}: let
inherit
(devicesFunctions)
dummy
;
in {
name = dummy;
label = "Canon-TR7620a";
ip = {
address0 = "";
};
}

View file

@ -0,0 +1,12 @@
{devicesFunctions}: let
inherit
(devicesFunctions)
dummy
;
in {
name = dummy;
label = "Brother-HL-2170W";
ip = {
address0 = "192.168.50.195";
};
}

View file

@ -0,0 +1,32 @@
{devicesFunctions}: let
inherit
(devicesFunctions)
fileModeAndDirMode
ownerExclusiveReadWriteMask
readWritePermissions
sambaPermissions
userIdForUser0
;
serverName = "server";
serverIP = "192.168.50.140";
serverStorageDriveName = "NAS1";
in {
label = "Server";
name = serverName;
ip = {
address0 = serverIP;
};
boot = {
options = ownerExclusiveReadWriteMask;
};
storage0 = {
mount = "/mnt/media/${serverStorageDriveName}";
device = "/dev/disk/by-label/${serverStorageDriveName}";
options = readWritePermissions;
};
samba0 = {
mount = "/mnt/media/${serverName}";
device = "//${serverIP}";
options = sambaPermissions ++ fileModeAndDirMode ++ userIdForUser0;
};
}

View file

@ -0,0 +1,40 @@
{devicesFunctions}: let
inherit
(devicesFunctions)
sambaPermissions
userIdForUser0
userIdForUser1
;
user0 = "nick";
user1 = "garnet";
user0Name = "Nick";
user1Name = "Garnet";
synologyName = "synology";
synologyIP = "192.168.50.209";
in {
label = "Synology";
sync = "MWRGX2V-F5XKE5E-REP6ECT-OOPFBMF-22NHSMW-YFBU6MB-PLFUN63-R3MW2QX";
name = synologyName;
ip = {
address0 = synologyIP;
};
# Nick Home Folder
folder0 = {
mount = "/mnt/media/${synologyName}/${user0}";
device = "//${synologyIP}/homes/${user0Name}";
options = sambaPermissions ++ userIdForUser0;
};
# Garnet Home Folder
folder1 = {
mount = "/mnt/media/${synologyName}/${user1}";
device = "//${synologyIP}/homes/${user1Name}";
options = sambaPermissions ++ userIdForUser1;
};
# Minecraft Worlds
folder2 = {
mount = "/home/${user1}/.local/share/PrismLauncher/instances/1.21/.minecraft/saves";
device = "//${synologyIP}/homes/${user1Name}/Minecraft";
options = sambaPermissions ++ userIdForUser1;
};
}

View file

@ -0,0 +1,13 @@
{devicesFunctions}: let
inherit
(devicesFunctions)
dummy
;
in {
name = "tablet";
label = dummy;
sync = "I2ZSCZU-T4JMUJJ-XCUQ3MY-G5EUFZ5-KRG2DRY-XIBJZZM-FQW3UMY-CBCTUQU";
ip = {
address0 = "192.168.50.189";
};
}

35
config/devices/default.nix Executable file
View file

@ -0,0 +1,35 @@
let
configPath = ./config;
printerPath = configPath + /printers;
devicesFunctions = {
ownerWriteOthersReadMask = ["fmask=0022" "dmask=0022"];
ownerExclusiveReadWriteMask = ["fmask=0077" "dmask=0077"];
readWritePermissions = ["rw"];
sambaPermissions = ["rw" "gid=100" "vers=3.0" "x-systemd.automount" "x-systemd.requires=network-online.target"];
fileModeAndDirMode = ["file_mode=0644" "dir_mode=0755"];
userIdForUser0 = ["uid=1000"];
userIdForUser1 = ["uid=1001"];
dummy = [];
};
deviceswithFunctions = builtins.listToAttrs (map (name: {
name = builtins.substring 0 (builtins.stringLength name - 4) name; # Remove the last 4 characters (".nix")
value = import (configPath + "/${name}") {inherit devicesFunctions;};
})
(builtins.filter (name:
builtins.match ".*\\.nix$" name != null) (builtins.attrNames
(builtins.readDir configPath))));
devicesPrinters = builtins.listToAttrs (map (name: {
name = builtins.substring 0 (builtins.stringLength name - 4) name; # Remove the last 4 characters (".nix")
value = import (printerPath + "/${name}") {inherit devicesFunctions;};
})
(builtins.filter (name:
builtins.match ".*\\.nix$" name != null) (builtins.attrNames
(builtins.readDir printerPath))));
devices = deviceswithFunctions // devicesPrinters;
in {
devices = devices;
}

View file

@ -1,431 +0,0 @@
let
jellyfinLabel = "Jellyfin";
jellyfinName = "jellyfin";
domain0 = "cloudbert.fun";
domain1 = "the-nutrivore.social";
domain2 = "the-nutrivore.com";
servicePath = "/mnt/media/NAS1";
sops = "/var/lib/secrets";
sslPath = "/var/lib/acme";
varLib = "/var/lib";
in {
instances = {
web = {
domains = {
url0 = domain0;
url1 = domain1;
url2 = domain2;
};
dns = {
provider0 = "namecheap";
};
localhost = {
address0 = "127.0.0.1"; # Local
address1 = "0.0.0.0"; # All
address2 = "192.168.50.1"; # Router
address3 = "192.168.50.0"; # Router
};
};
acme = let
acmeLabel = "Acme";
acmeName = "acme";
in {
label = acmeLabel;
name = acmeName;
paths = {
path0 = sslPath;
};
sops = {
path0 = "${sops}/${acmeName}";
};
};
caddy = let
caddyLabel = "Caddy";
caddyName = "caddy";
in {
label = caddyLabel;
name = caddyName;
sops = {
path0 = "${sops}/${caddyName}";
};
ports = {
port0 = 80;
port1 = 443;
};
};
castopod = let
castopodLabel = "Castopod";
castopodName = "castopod";
castopodSubdomain = "podcast";
in {
label = castopodLabel;
name = castopodName;
email = {
address0 = "noreply@${castopodSubdomain}.${domain1}";
};
sops = {
path0 = "${sops}/${castopodName}";
};
subdomain = castopodSubdomain;
paths = {
path0 = "${servicePath}/${castopodLabel}";
};
ports = {
port0 = 8000;
};
ssl = {
cert = "${sslPath}/${castopodSubdomain}.${domain1}/fullchain.pem";
key = "${sslPath}/${castopodSubdomain}.${domain1}/key.pem";
};
};
forgejo = let
forgejoLabel = "Forgejo";
forgejoName = "forgejo";
forgejoSubdomain = "source";
in {
label = forgejoLabel;
name = forgejoName;
email = {
address0 = "noreply@${forgejoSubdomain}.${domain1}";
};
sops = {
path0 = "${sops}/${forgejoName}";
};
subdomain = forgejoSubdomain;
paths = {
path0 = "${servicePath}/${forgejoLabel}";
};
ports = {
port0 = 3033;
};
ssl = {
cert = "${sslPath}/${forgejoSubdomain}.${domain1}/fullchain.pem";
key = "${sslPath}/${forgejoSubdomain}.${domain1}/key.pem";
};
};
jellyfin = {
label = jellyfinLabel;
name = jellyfinName;
sops = {
path0 = "${sops}/${jellyfinName}";
};
subdomain = jellyfinName;
paths = {
path0 = "${servicePath}/${jellyfinLabel}";
};
ports = {
port0 = 5055; # Jellyseer
port1 = 8096; # Jellyfin HTTP
port2 = 8920; # Jellyfin HTTPS
};
ssl = {
cert = "${sslPath}/${jellyfinName}.${domain0}/fullchain.pem";
key = "${sslPath}/${jellyfinName}.${domain0}/key.pem";
};
};
matrix = let
matrixLabel = "Matrix";
matrixName = "matrix";
in {
label = matrixLabel;
name = matrixName;
sops = {
path0 = "${sops}/${matrixName}";
};
subdomain = matrixName;
paths = {
path0 = "${servicePath}/${matrixLabel}";
path1 = "";
path2 = "";
};
};
mastodon = let
mastodonLabel = "Mastodon";
mastodonName = "mastodon";
in {
label = mastodonLabel;
name = mastodonName;
email = {
address0 = "thenutrivore@${domain1}";
};
sops = {
path0 = "${sops}/${mastodonName}";
};
paths = {
path0 = "${servicePath}/${mastodonLabel}";
path1 = "";
path2 = "";
};
ssl = {
cert = "${sslPath}/${domain1}/fullchain.pem";
key = "${sslPath}/${domain1}/key.pem";
};
};
minecraft = let
minecraftLabel = "Minecraft";
minecraftName = "minecraft";
in {
label = minecraftLabel;
name = minecraftName;
sops = {
path0 = "${sops}/${minecraftName}";
};
subdomain = minecraftName;
paths = {
path0 = "${servicePath}/${minecraftLabel}";
};
ports = {
port0 = 43000; # Minecraft (Brix on Nix)
};
ssl = {
cert = "${sslPath}/${minecraftName}.${domain0}/fullchain.pem";
key = "${sslPath}/${minecraftName}.${domain0}/key.pem";
};
};
nextcloud = let
nextcloudLabel = "Nextcloud";
nextcloudName = "nextcloud";
in {
label = nextcloudLabel;
name = nextcloudName;
sops = {
path0 = "${sops}/${nextcloudName}";
};
subdomain = nextcloudName;
paths = {
path0 = "${servicePath}/${nextcloudLabel}";
};
ports = {
port0 = 8354; # Nextcloud
};
ssl = {
cert = "${sslPath}/${nextcloudName}.${domain1}/fullchain.pem";
key = "${sslPath}/${nextcloudName}.${domain1}/key.pem";
};
};
nginx = {
ports = {
port0 = 8080; # HTTP
port1 = 8443; # HTTPS
};
};
ollama = let
ollamaLabel = "Ollama";
ollamaName = "ollama";
in {
label = ollamaLabel;
name = ollamaName;
sops = {
path0 = "${sops}/${ollamaName}";
};
subdomain = ollamaName;
paths = {
path0 = "${servicePath}/${ollamaLabel}";
path1 = "/mnt/media/storage/${ollamaName}";
};
ports = {
port0 = 8088; # Open-WebUI (Ollama Front End)
port1 = 11434; # Ollama API
};
ssl = {
cert = "${sslPath}/${ollamaName}.${domain0}/fullchain.pem";
key = "${sslPath}/${ollamaName}.${domain0}/key.pem";
};
};
owncast = let
owncastLabel = "Owncast";
owncastName = "owncast";
owncastSubdomain = "stream";
in {
label = owncastLabel;
name = owncastName;
sops = {
path0 = "${sops}/${owncastName}";
};
subdomain = owncastSubdomain;
paths = {
path0 = "${servicePath}/${owncastLabel}";
path1 = "/mnt/media/storage/${owncastName}";
};
ports = {
port0 = 9454;
port1 = 1935;
};
ssl = {
cert = "${sslPath}/${owncastSubdomain}.${domain1}/fullchain.pem";
key = "${sslPath}/${owncastSubdomain}.${domain1}/key.pem";
};
};
peertube = let
peertubeLabel = "PeerTube";
peertubeName = "peertube";
peertubeSubdomain = "video";
in {
label = peertubeLabel;
name = peertubeName;
email = {
address0 = "noreply@${peertubeSubdomain}.${domain1}";
};
sops = {
path0 = "${sops}/${peertubeName}";
};
subdomain = peertubeSubdomain;
paths = {
path0 = "${servicePath}/${peertubeLabel}";
};
ports = {
port0 = 9000; # HTTP
port1 = 1935;
port2 = 1936;
port3 = 5432;
port4 = 52800;
};
ssl = {
cert = "${sslPath}/video.${domain1}/fullchain.pem";
key = "${sslPath}/video.${domain1}/key.pem";
};
};
postgresql = let
postgresLabel = "PostgreSQL";
postgresName = "postgres";
in {
label = postgresLabel;
name = postgresName;
sops = {
path0 = "${sops}/${postgresName}";
};
paths = {
path0 = "${servicePath}/${postgresLabel}";
};
ports = {
port0 = 5432;
};
};
samba = let
sambaLabel = "Samba";
sambaName = "samba";
in {
label = sambaLabel;
name = sambaName;
sops = {
path0 = "${sops}/${sambaName}";
};
paths = {
path0 = "${servicePath}/${jellyfinLabel}";
path1 = jellyfinName;
path2 = "";
};
ports = {
port0 = 445; # Samba
};
};
syncthing = let
syncthingLabel = "Syncthing";
syncthingName = "syncthing";
in {
label = syncthingLabel;
name = syncthingName;
sops = {
path0 = "${sops}/${syncthingName}";
};
subdomain = syncthingName;
ports = {
port0 = 8388; # Syncthing (WebUI)
port1 = 21027; # Syncthing (Discovery)
port2 = 22000; # Syncthing (Transfer)
};
ssl = {
cert = "${sslPath}/${syncthingName}.${domain0}/fullchain.pem";
key = "${sslPath}/${syncthingName}.${domain0}/key.pem";
};
};
synology = let
synologyLabel = "Synology";
synologyName = "synology";
in {
label = synologyLabel;
name = synologyName;
sops = {
path0 = "${sops}/${synologyName}";
};
ports = {
port0 = 5001; # Synology HTTPS
};
};
vaultwarden = let
vaultwardenLabel = "Vaultwarden";
vaultwardenName = "vaultwarden";
in {
label = vaultwardenLabel;
name = vaultwardenName;
email = {
address0 = "noreply@${vaultwardenName}.${domain0}";
};
sops = {
path0 = "${sops}/${vaultwardenName}";
};
subdomain = vaultwardenName;
paths = {
path0 = "${servicePath}/${vaultwardenLabel}/BackupDir";
};
ports = {
port0 = 8085; # Vaultwarden WebUI
};
ssl = {
cert = "${sslPath}/${vaultwardenName}.${domain0}/fullchain.pem";
key = "${sslPath}/${vaultwardenName}.${domain0}/key.pem";
};
};
wiki = let
wikiLabel = "Wiki-js";
wikiName = "wiki-js";
wikiSubdomain = "vault";
in {
label = wikiLabel;
name = wikiName;
sops = {
path0 = "${sops}/${wikiName}";
};
subdomain = wikiSubdomain;
paths = {
path0 = "${servicePath}/${wikiLabel}";
path1 = "${varLib}/DataDir";
};
ports = {
port0 = 3000;
port1 = 5432;
};
ssl = {
cert = "${sslPath}/${wikiSubdomain}.${domain1}/fullchain.pem";
key = "${sslPath}/${wikiSubdomain}.${domain1}/key.pem";
};
};
writefreely = let
writefreelyLabel = "WriteFreely";
writefreelyName = "writefreely";
writefreelySubdomain = "blog";
in {
label = writefreelyLabel;
name = writefreelyName;
sops = {
path0 = "${sops}/${writefreelyName}";
};
subdomain = writefreelySubdomain;
paths = {
path0 = "${servicePath}/${writefreelyLabel}/BackupDir";
};
ports = {
port0 = 8093;
};
ssl = {
cert = "${sslPath}/${writefreelySubdomain}.${domain1}/fullchain.pem";
key = "${sslPath}/${writefreelySubdomain}.${domain1}/key.pem";
};
};
};
}

View file

@ -0,0 +1,15 @@
{instancesFunctions}: let
inherit (instancesFunctions) sslPath sopsPath;
acmeLabel = "Acme";
acmeName = "acme";
in {
label = acmeLabel;
name = acmeName;
paths = {
path0 = sslPath;
};
sops = {
path0 = "${sopsPath}/${acmeName}";
};
}

View file

@ -0,0 +1,16 @@
{instancesFunctions}: let
inherit (instancesFunctions) sopsPath;
caddyLabel = "Caddy";
caddyName = "caddy";
in {
label = caddyLabel;
name = caddyName;
sops = {
path0 = "${sopsPath}/${caddyName}";
};
ports = {
port0 = 80;
port1 = 443;
};
}

View file

@ -0,0 +1,26 @@
{instancesFunctions}: let
inherit (instancesFunctions) domain1 servicePath sslPath sopsPath;
castopodLabel = "Castopod";
castopodName = "castopod";
castopodSubdomain = "podcast";
in {
label = castopodLabel;
name = castopodName;
email = {
address0 = "noreply@${castopodSubdomain}.${domain1}";
};
sops = {
path0 = "${sopsPath}/${castopodName}";
};
subdomain = castopodSubdomain;
paths = {
path0 = "${servicePath}/${castopodLabel}";
};
ports = {
port0 = 8000;
};
ssl = {
cert = "${sslPath}/${castopodSubdomain}.${domain1}/fullchain.pem";
key = "${sslPath}/${castopodSubdomain}.${domain1}/key.pem";
};
}

View file

@ -0,0 +1,27 @@
{instancesFunctions}: let
inherit (instancesFunctions) domain1 servicePath sslPath sopsPath;
forgejoLabel = "Forgejo";
forgejoName = "forgejo";
forgejoSubdomain = "source";
in {
label = forgejoLabel;
name = forgejoName;
email = {
address0 = "noreply@${forgejoSubdomain}.${domain1}";
};
sops = {
path0 = "${sopsPath}/${forgejoName}";
};
subdomain = forgejoSubdomain;
paths = {
path0 = "${servicePath}/${forgejoLabel}";
};
ports = {
port0 = 3033;
};
ssl = {
cert = "${sslPath}/${forgejoSubdomain}.${domain1}/fullchain.pem";
key = "${sslPath}/${forgejoSubdomain}.${domain1}/key.pem";
};
}

View file

@ -0,0 +1,22 @@
{instancesFunctions}: let
inherit (instancesFunctions) domain0 jellyfinLabel jellyfinName servicePath sslPath sopsPath;
in {
label = jellyfinLabel;
name = jellyfinName;
sops = {
path0 = "${sopsPath}/${jellyfinName}";
};
subdomain = jellyfinName;
paths = {
path0 = "${servicePath}/${jellyfinLabel}";
};
ports = {
port0 = 5055; # Jellyseer
port1 = 8096; # Jellyfin HTTP
port2 = 8920; # Jellyfin HTTPS
};
ssl = {
cert = "${sslPath}/${jellyfinName}.${domain0}/fullchain.pem";
key = "${sslPath}/${jellyfinName}.${domain0}/key.pem";
};
}

View file

@ -0,0 +1,24 @@
{instancesFunctions}: let
inherit (instancesFunctions) domain1 servicePath sslPath sopsPath;
mastodonLabel = "Mastodon";
mastodonName = "mastodon";
in {
label = mastodonLabel;
name = mastodonName;
email = {
address0 = "thenutrivore@${domain1}";
};
sops = {
path0 = "${sopsPath}/${mastodonName}";
};
paths = {
path0 = "${servicePath}/${mastodonLabel}";
path1 = "";
path2 = "";
};
ssl = {
cert = "${sslPath}/${domain1}/fullchain.pem";
key = "${sslPath}/${domain1}/key.pem";
};
}

View file

@ -0,0 +1,18 @@
{instancesFunctions}: let
inherit (instancesFunctions) servicePath sopsPath;
matrixLabel = "Matrix";
matrixName = "matrix";
in {
label = matrixLabel;
name = matrixName;
sops = {
path0 = "${sopsPath}/${matrixName}";
};
subdomain = matrixName;
paths = {
path0 = "${servicePath}/${matrixLabel}";
path1 = "";
path2 = "";
};
}

View file

@ -0,0 +1,23 @@
{instancesFunctions}: let
inherit (instancesFunctions) domain0 servicePath sslPath sopsPath;
minecraftLabel = "Minecraft";
minecraftName = "minecraft";
in {
label = minecraftLabel;
name = minecraftName;
sops = {
path0 = "${sopsPath}/${minecraftName}";
};
subdomain = minecraftName;
paths = {
path0 = "${servicePath}/${minecraftLabel}";
};
ports = {
port0 = 43000; # Minecraft (Brix on Nix)
};
ssl = {
cert = "${sslPath}/${minecraftName}.${domain0}/fullchain.pem";
key = "${sslPath}/${minecraftName}.${domain0}/key.pem";
};
}

View file

@ -0,0 +1,23 @@
{instancesFunctions}: let
inherit (instancesFunctions) domain1 servicePath sslPath sopsPath;
nextcloudLabel = "Nextcloud";
nextcloudName = "nextcloud";
in {
label = nextcloudLabel;
name = nextcloudName;
sops = {
path0 = "${sopsPath}/${nextcloudName}";
};
subdomain = nextcloudName;
paths = {
path0 = "${servicePath}/${nextcloudLabel}";
};
ports = {
port0 = 8354; # Nextcloud
};
ssl = {
cert = "${sslPath}/${nextcloudName}.${domain1}/fullchain.pem";
key = "${sslPath}/${nextcloudName}.${domain1}/key.pem";
};
}

View file

@ -0,0 +1,16 @@
{instancesFunctions}: let
inherit (instancesFunctions) sopsPath;
nginxLabel = "Ngnix";
nginxName = "nginx";
in {
name = nginxName;
label = nginxLabel;
sops = {
path0 = "${sopsPath}/${nginxName}";
};
ports = {
port0 = 8080; # HTTP
port1 = 8443; # HTTPS
};
}

View file

@ -0,0 +1,25 @@
{instancesFunctions}: let
inherit (instancesFunctions) domain0 servicePath sslPath sopsPath;
ollamaLabel = "Ollama";
ollamaName = "ollama";
in {
label = ollamaLabel;
name = ollamaName;
sops = {
path0 = "${sopsPath}/${ollamaName}";
};
subdomain = ollamaName;
paths = {
path0 = "${servicePath}/${ollamaLabel}";
path1 = "/mnt/media/storage/${ollamaName}";
};
ports = {
port0 = 8088; # Open-WebUI (Ollama Front End)
port1 = 11434; # Ollama API
};
ssl = {
cert = "${sslPath}/${ollamaName}.${domain0}/fullchain.pem";
key = "${sslPath}/${ollamaName}.${domain0}/key.pem";
};
}

View file

@ -0,0 +1,26 @@
{instancesFunctions}: let
inherit (instancesFunctions) domain1 servicePath sslPath sopsPath;
owncastLabel = "Owncast";
owncastName = "owncast";
owncastSubdomain = "stream";
in {
label = owncastLabel;
name = owncastName;
sops = {
path0 = "${sopsPath}/${owncastName}";
};
subdomain = owncastSubdomain;
paths = {
path0 = "${servicePath}/${owncastLabel}";
path1 = "/mnt/media/storage/${owncastName}";
};
ports = {
port0 = 9454;
port1 = 1935;
};
ssl = {
cert = "${sslPath}/${owncastSubdomain}.${domain1}/fullchain.pem";
key = "${sslPath}/${owncastSubdomain}.${domain1}/key.pem";
};
}

View file

@ -0,0 +1,31 @@
{instancesFunctions}: let
inherit (instancesFunctions) domain1 servicePath sslPath sopsPath;
peertubeLabel = "PeerTube";
peertubeName = "peertube";
peertubeSubdomain = "video";
in {
label = peertubeLabel;
name = peertubeName;
email = {
address0 = "noreply@${peertubeSubdomain}.${domain1}";
};
sops = {
path0 = "${sopsPath}/${peertubeName}";
};
subdomain = peertubeSubdomain;
paths = {
path0 = "${servicePath}/${peertubeLabel}";
};
ports = {
port0 = 9000; # HTTP
port1 = 1935;
port2 = 1936;
port3 = 5432;
port4 = 52800;
};
ssl = {
cert = "${sslPath}/video.${domain1}/fullchain.pem";
key = "${sslPath}/video.${domain1}/key.pem";
};
}

View file

@ -0,0 +1,18 @@
{instancesFunctions}: let
inherit (instancesFunctions) servicePath sopsPath;
postgresLabel = "PostgreSQL";
postgresName = "postgres";
in {
label = postgresLabel;
name = postgresName;
sops = {
path0 = "${sopsPath}/${postgresName}";
};
paths = {
path0 = "${servicePath}/${postgresLabel}";
};
ports = {
port0 = 5432;
};
}

View file

@ -0,0 +1,20 @@
{instancesFunctions}: let
inherit (instancesFunctions) jellyfinLabel jellyfinName servicePath sopsPath;
sambaLabel = "Samba";
sambaName = "samba";
in {
label = sambaLabel;
name = sambaName;
sops = {
path0 = "${sopsPath}/${sambaName}";
};
paths = {
path0 = "${servicePath}/${jellyfinLabel}";
path1 = jellyfinName;
path2 = "";
};
ports = {
port0 = 445; # Samba
};
}

View file

@ -0,0 +1,22 @@
{instancesFunctions}: let
inherit (instancesFunctions) domain0 sslPath sopsPath;
syncthingLabel = "Syncthing";
syncthingName = "syncthing";
in {
label = syncthingLabel;
name = syncthingName;
sops = {
path0 = "${sopsPath}/${syncthingName}";
};
subdomain = syncthingName;
ports = {
port0 = 8388; # Syncthing (WebUI)
port1 = 21027; # Syncthing (Discovery)
port2 = 22000; # Syncthing (Transfer)
};
ssl = {
cert = "${sslPath}/${syncthingName}.${domain0}/fullchain.pem";
key = "${sslPath}/${syncthingName}.${domain0}/key.pem";
};
}

View file

@ -0,0 +1,15 @@
{instancesFunctions}: let
inherit (instancesFunctions) sopsPath;
synologyLabel = "Synology";
synologyName = "synology";
in {
label = synologyLabel;
name = synologyName;
sops = {
path0 = "${sopsPath}/${synologyName}";
};
ports = {
port0 = 5001; # Synology HTTPS
};
}

View file

@ -0,0 +1,26 @@
{instancesFunctions}: let
inherit (instancesFunctions) domain0 servicePath sslPath sopsPath;
vaultwardenLabel = "Vaultwarden";
vaultwardenName = "vaultwarden";
in {
label = vaultwardenLabel;
name = vaultwardenName;
email = {
address0 = "noreply@${vaultwardenName}.${domain0}";
};
sops = {
path0 = "${sopsPath}/${vaultwardenName}";
};
subdomain = vaultwardenName;
paths = {
path0 = "${servicePath}/${vaultwardenLabel}/BackupDir";
};
ports = {
port0 = 8085; # Vaultwarden WebUI
};
ssl = {
cert = "${sslPath}/${vaultwardenName}.${domain0}/fullchain.pem";
key = "${sslPath}/${vaultwardenName}.${domain0}/key.pem";
};
}

View file

@ -0,0 +1,18 @@
{instancesFunctions}: let
inherit (instancesFunctions) domain0 domain1 domain2;
in {
domains = {
url0 = domain0;
url1 = domain1;
url2 = domain2;
};
dns = {
provider0 = "namecheap";
};
localhost = {
address0 = "127.0.0.1"; # Local
address1 = "0.0.0.0"; # All
address2 = "192.168.50.1"; # Router
address3 = "192.168.50.0"; # Router
};
}

View file

@ -0,0 +1,26 @@
{instancesFunctions}: let
inherit (instancesFunctions) domain1 servicePath sslPath sopsPath varLib;
wikiLabel = "Wiki-js";
wikiName = "wiki-js";
wikiSubdomain = "vault";
in {
label = wikiLabel;
name = wikiName;
sops = {
path0 = "${sopsPath}/${wikiName}";
};
subdomain = wikiSubdomain;
paths = {
path0 = "${servicePath}/${wikiLabel}";
path1 = "${varLib}/DataDir";
};
ports = {
port0 = 3000;
port1 = 5432;
};
ssl = {
cert = "${sslPath}/${wikiSubdomain}.${domain1}/fullchain.pem";
key = "${sslPath}/${wikiSubdomain}.${domain1}/key.pem";
};
}

View file

@ -0,0 +1,24 @@
{instancesFunctions}: let
inherit (instancesFunctions) domain1 servicePath sslPath sopsPath;
writefreelyLabel = "WriteFreely";
writefreelyName = "writefreely";
writefreelySubdomain = "blog";
in {
label = writefreelyLabel;
name = writefreelyName;
sops = {
path0 = "${sopsPath}/${writefreelyName}";
};
subdomain = writefreelySubdomain;
paths = {
path0 = "${servicePath}/${writefreelyLabel}/BackupDir";
};
ports = {
port0 = 8093;
};
ssl = {
cert = "${sslPath}/${writefreelySubdomain}.${domain1}/fullchain.pem";
key = "${sslPath}/${writefreelySubdomain}.${domain1}/key.pem";
};
}

25
config/instances/default.nix Executable file
View file

@ -0,0 +1,25 @@
let
configPath = ./config;
instancesFunctions = {
jellyfinLabel = "Jellyfin";
jellyfinName = "jellyfin";
domain0 = "cloudbert.fun";
domain1 = "the-nutrivore.social";
domain2 = "the-nutrivore.com";
servicePath = "/mnt/media/NAS1";
sopsPath = "/var/lib/secrets";
sslPath = "/var/lib/acme";
varLib = "/var/lib";
};
instances = builtins.listToAttrs (map (name: {
name = builtins.substring 0 (builtins.stringLength name - 4) name; # Remove the last 4 characters (".nix")
value = import (configPath + "/${name}") {inherit instancesFunctions;};
})
(builtins.filter (name:
builtins.match ".*\\.nix$" name != null) (builtins.attrNames
(builtins.readDir configPath))));
in {
instances = instances;
}

View file

@ -1,36 +0,0 @@
let
user0 = "nick";
user1 = "garnet";
in {
inherit
user0
user1
;
users = {
"${user0}" = {
name = "Nick";
aliases = {
name0 = "BRBWaffles";
name1 = "brbwaffles";
name2 = "Nutrivore";
name3 = "nutrivore";
};
email = {
address0 = "nickjhiebert@proton.me";
address1 = "thenutrivore@proton.me";
};
paths = {
path0 = "/home/${user0}/Files/Projects"; # Git path
};
sshKeys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBF9TmImDoYDpsW5VMFbOcuK3aH4TWRtx/xGxT3yUtEN nick@desktop"
];
};
"${user1}" = {
name = "Garnet";
email = {
address0 = "ninaeffler@gmail.com";
};
};
};
}

View file

@ -0,0 +1,21 @@
{user0}: let
inherit user0;
in {
name = "Nick";
aliases = {
name0 = "BRBWaffles";
name1 = "brbwaffles";
name2 = "Nutrivore";
name3 = "nutrivore";
};
email = {
address0 = "nickjhiebert@proton.me";
address1 = "thenutrivore@proton.me";
};
paths = {
path0 = "/home/${user0}/Files/Projects"; # Git path
};
sshKeys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBF9TmImDoYDpsW5VMFbOcuK3aH4TWRtx/xGxT3yUtEN nick@desktop"
];
}

View file

@ -0,0 +1,11 @@
{user1}: let
inherit user1;
in {
name = "Garnet";
email = {
address0 = "ninaeffler@gmail.com";
};
paths = {
path0 = "/home/${user1}/Files/Projects"; # Git path
};
}

15
config/users/default.nix Executable file
View file

@ -0,0 +1,15 @@
let
configPath = ./config;
user0 = "nick";
user1 = "garnet";
in {
inherit
user0
user1
;
users = {
"${user0}" = import (configPath + "/user0.nix") {inherit user0;};
"${user1}" = import (configPath + "/user1.nix") {inherit user1;};
};
}