refactor module system

This commit is contained in:
2026-11-08 15:22:26 +01:00
parent d4ef8af473
commit c5bb5cc965
40 changed files with 30 additions and 35 deletions
+12
View File
@@ -0,0 +1,12 @@
{
imports = [
./shares
./slskd.nix
./navidrome.nix
./services.nix
./zfs.nix
./firewall.nix
./grafana.nix
../scripts.nix
];
}
+10
View File
@@ -0,0 +1,10 @@
{
networking.firewall.allowedTCPPorts = [
2049
5030
3900
3901
3902
3903
];
}
+34
View File
@@ -0,0 +1,34 @@
{
services.grafana = {
enable = true;
openFirewall = true;
settings = {
security.secret_key = "$__file{/run/secrets/grafana/secret_key};";
server = {
http_addr = "0.0.0.0";
http_port = 3000;
enable_gzip = true;
domain = "192.168.132.149";
};
analytics.reporting_enabled = false;
};
};
services.prometheus = {
enable = true;
globalConfig.scrape_interval = "10s";
scrapeConfigs = [
{
job_name = "navidrome";
scheme = "http";
metrics_path = "/metrics";
static_configs = [
{
targets = [ "localhost:4533" ];
}
];
}
];
};
}
+25
View File
@@ -0,0 +1,25 @@
{ lib, ... }:
{
services.navidrome = {
enable = true;
user = "user";
openFirewall = true;
settings = {
MusicFolder = "/home/user/Music";
PlaylistsPath = "Playlists";
Address = "0.0.0.0";
ScanSchedule = "@daily";
EnableInsightsCollector = false;
Scanner.PurgeMissing = "always";
CoverArtPriority = "embedded, cover.*, folder.*, front.*, jacket.*, *, external";
pid.album = "folder";
Subsonic.DefaultReportRealPath = true;
prometheus.enabled = true;
};
};
systemd.services.navidrome.serviceConfig = {
ProtectHome = lib.mkForce false;
};
}
+31
View File
@@ -0,0 +1,31 @@
{ pkgs, ... }:
{
systemd.timers."bc-wishlist-scraper" = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "daily";
Unit = "bc-wishlist-scraper.service";
};
};
systemd.services."bc-wishlist-scraper" = {
script = ''
${pkgs.bash}/bin/bash /home/user/bc-wishlist-scraper/run.sh
'';
};
systemd.user.timers."scdl" = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "daily";
Unit = "scdl.service";
};
};
systemd.user.services."scdl" = {
script = ''
cd ~/Music/scdl && ${pkgs.scdl}/bin/scdl me -f -c --download-archive archive.txt
'';
};
}
+7
View File
@@ -0,0 +1,7 @@
{
imports = [
./garage.nix
./smb.nix
./nfs.nix
];
}
+29
View File
@@ -0,0 +1,29 @@
{ pkgs, ... }:
{
services.garage = {
enable = false;
package = pkgs.garage;
environmentFile = "/home/user/garage_secrets";
settings = {
db_engine = "sqlite";
rpc_bind_addr = "0.0.0.0:3901";
# rpc_public_addr = "garage.example.com:3901";
replication_factor = 1;
s3_api = {
s3_region = "garage";
api_bind_addr = "0.0.0.0:3900";
};
# s3_web = {
# bind_addr = "0.0.0.0:3902";
# };
admin = {
api_bind_addr = "0.0.0.0:3903";
};
};
};
}
+15
View File
@@ -0,0 +1,15 @@
{
services.nfs.server = {
enable = true;
exports = {
"/media/music" = {
"192.168.132.0/24" = [
"rw"
"async"
"no_subtree_check"
"fsid=1"
];
};
};
};
}
+24
View File
@@ -0,0 +1,24 @@
{
services.samba = {
enable = true;
openFirewall = true;
settings = {
global = {
"workgroup" = "WORKGROUP";
"server string" = "smbnix";
"security" = "user";
"interfaces" = "lo eno1 tailscale0";
"hosts allow" = "192.168.132.0/24 100.64.0.0/10 127.0.0.1 localhost";
"hosts deny" = "0.0.0.0/0";
"guest account" = "nobody";
};
"Music" = {
"path" = "/media/music";
"browseable" = "yes";
"read only" = "no";
"guest ok" = "no";
"valid users" = "user";
};
};
};
}
+120
View File
@@ -0,0 +1,120 @@
{ pkgs, ... }:
{
services.slskd = {
enable = true;
environmentFile = /run/secrets/slskd_secrets;
openFirewall = true;
user = "user";
settings = {
remote_file_management = true;
directories = {
downloads = "/media/music/Soulseek";
};
shares = {
directories = [
"/media/music/Tracks"
"/media/music/Tracks2"
"/media/music/samples"
];
};
rooms = [
"Rare Music"
"nicotine"
"! ! LGBTQ+ ! !"
"lossless"
"Linux"
"Breakcore"
"Jungle"
];
transfers = {
upload = {
speed_limit = 3700;
};
groups = {
blacklisted = {
members = [
"relay"
"smbd"
];
};
user_defined = {
my_buddies = {
upload = {
priority = 1;
strategy = "firstinfirstout";
slots = 1000;
};
members = [
"noamifur"
"mesityl"
"diphenhydramine"
"monfi"
];
};
};
};
};
soulseek = {
description = ''
Fuck DRM. Fuck Spotify
Discord: keksnino
https://www.last.fm/user/KeksNino
also check out @musicpuppy
'';
listen_port = 32895;
};
feature = {
swagger = true;
};
integrations = {
webhooks = {
discord_relay = {
call = {
url = "http://localhost:5001/slskd_webhook";
};
on = [ "UploadFileComplete" ];
timeout = 5000;
retry = {
attempts = 3;
};
};
};
};
retention = {
files = {
incomplete = 20160;
};
};
};
};
systemd.user.services.slskd-speed = {
enable = true;
description = "Soulseek True Speed Shower";
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
Environment = "PYTHONUNBUFFERED=1";
Restart = "on-failure";
RestartSec = 30;
StandardOutput = "journal";
StandardError = "journal";
EnvironmentFile = "/run/secrets/slskd_secrets";
ExecStart = ''
${pkgs.python3}/bin/python3 /home/user/slskd-speed.py \
-u "$SLSKD_SLSK_USERNAME" \
-p "$SLSKD_SLSK_PASSWORD" \
-s 30mbit/s \
--slskd-url http://localhost:5030 \
--slskd-key "$SLSKD_API_KEY" \
--loop \
--poll-interval 30 \
--interval 900
'';
};
};
}
+43
View File
@@ -0,0 +1,43 @@
{
boot.loader.grub = {
enable = true;
zfsSupport = true;
efiSupport = true;
efiInstallAsRemovable = true;
mirroredBoots = [
{
devices = [ "nodev" ];
path = "/boot";
}
];
};
fileSystems."/" = {
device = "zpool/root";
fsType = "zfs";
};
fileSystems."/nix" = {
device = "zpool/nix";
fsType = "zfs";
};
fileSystems."/var" = {
device = "zpool/var";
fsType = "zfs";
};
fileSystems."/home" = {
device = "zpool/home";
fsType = "zfs";
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/FCFD-4472";
fsType = "vfat";
};
boot.zfs.forceImportRoot = false;
services.zfs.autoScrub.enable = true;
swapDevices = [ ];
services.zfs.autoSnapshot = {
enable = true;
};
}