Compare commits
8 Commits
196f06e41f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f949f13d1 | |||
| 59080fe1b3 | |||
| 12fca8840d | |||
| 49f06fc26c | |||
| 2c0811cfe9 | |||
| 9692fe5f08 | |||
| c142b5d045 | |||
|
16c84fdcb6
|
@@ -19,7 +19,6 @@
|
|||||||
./modules/secureboot.nix
|
./modules/secureboot.nix
|
||||||
./modules/no-rgb.nix
|
./modules/no-rgb.nix
|
||||||
./modules/security.nix
|
./modules/security.nix
|
||||||
./modules/arr-init.nix
|
|
||||||
./modules/ntfy-alerts.nix
|
./modules/ntfy-alerts.nix
|
||||||
|
|
||||||
./services/postgresql.nix
|
./services/postgresql.nix
|
||||||
@@ -158,6 +157,12 @@
|
|||||||
|
|
||||||
# Higher backlog for the large number of concurrent torrent connections
|
# Higher backlog for the large number of concurrent torrent connections
|
||||||
"net.core.netdev_max_backlog" = 5000;
|
"net.core.netdev_max_backlog" = 5000;
|
||||||
|
|
||||||
|
# Minecraft server optimizations
|
||||||
|
# Disable autogroup for better scheduling of game server threads
|
||||||
|
"kernel.sched_autogroup_enabled" = 0;
|
||||||
|
# Huge pages for Minecraft JVM (4000MB heap / 2MB per page + ~200 overhead)
|
||||||
|
"vm.nr_hugepages" = 2200;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
81
flake.lock
generated
81
flake.lock
generated
@@ -25,13 +25,33 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"arr-init": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1772249948,
|
||||||
|
"narHash": "sha256-v68tO12mTCET68eZG583U+OlBL4f6kAoHS9iKA/xLzQ=",
|
||||||
|
"ref": "refs/heads/main",
|
||||||
|
"rev": "d21eb9f5b0a30bb487de7c0afbbbaf19324eaa49",
|
||||||
|
"revCount": 1,
|
||||||
|
"type": "git",
|
||||||
|
"url": "ssh://gitea@git.gardling.com/titaniumtown/arr-init"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "ssh://gitea@git.gardling.com/titaniumtown/arr-init"
|
||||||
|
}
|
||||||
|
},
|
||||||
"crane": {
|
"crane": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1771121070,
|
"lastModified": 1771796463,
|
||||||
"narHash": "sha256-aIlv7FRXF9q70DNJPI237dEDAznSKaXmL5lfK/Id/bI=",
|
"narHash": "sha256-9bCDuUzpwJXcHMQYMS1yNuzYMmKO/CCwCexpjWOl62I=",
|
||||||
"owner": "ipetkov",
|
"owner": "ipetkov",
|
||||||
"repo": "crane",
|
"repo": "crane",
|
||||||
"rev": "a2812c19f1ed2e5ed5ce2ef7109798b575c180e1",
|
"rev": "3d3de3313e263e04894f284ac18177bd26169bad",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -177,11 +197,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1771744638,
|
"lastModified": 1772020340,
|
||||||
"narHash": "sha256-EDLi+YAsEEAmMeZe1v6GccuGRbCkpSZp/+A6g+pivR8=",
|
"narHash": "sha256-aqBl3GNpCadMoJ/hVkWTijM1Aeilc278MjM+LA3jK6g=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "cb6c151f5c9db4df0b69d06894dc8484de1f16a0",
|
"rev": "36e38ca0d9afe4c55405fdf22179a5212243eecc",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -243,11 +263,11 @@
|
|||||||
"rust-overlay": "rust-overlay"
|
"rust-overlay": "rust-overlay"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1771834715,
|
"lastModified": 1772216104,
|
||||||
"narHash": "sha256-5VI2KiMifx3Dca7nDJzctO3HpnS6zrvesdkLoZBrQRY=",
|
"narHash": "sha256-1TnGN26vnCEQk5m4AavJZxGZTb/6aZyphemRPRwFUfs=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "lanzaboote",
|
"repo": "lanzaboote",
|
||||||
"rev": "b798c53da0f7e521317a5413335096a21070cf0b",
|
"rev": "dbe5112de965bbbbff9f0729a9789c20a65ab047",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -265,11 +285,11 @@
|
|||||||
"systems": "systems_3"
|
"systems": "systems_3"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1771641457,
|
"lastModified": 1772160153,
|
||||||
"narHash": "sha256-TIekRGfeCwuEmYcWex40RTx0Gd46pqmyUtxdFKb5juI=",
|
"narHash": "sha256-lk5IxQzY9ZeeEyjKNT7P6dFnlRpQgkus4Ekc/+slypY=",
|
||||||
"owner": "Infinidoge",
|
"owner": "Infinidoge",
|
||||||
"repo": "nix-minecraft",
|
"repo": "nix-minecraft",
|
||||||
"rev": "c4e2b8969e09067da9d44b6b5762e1e896418f40",
|
"rev": "deca3fb710b502ba10cd5cdc8f66c2cc184b92df",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -280,11 +300,11 @@
|
|||||||
},
|
},
|
||||||
"nixos-hardware": {
|
"nixos-hardware": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1771423359,
|
"lastModified": 1771969195,
|
||||||
"narHash": "sha256-yRKJ7gpVmXbX2ZcA8nFi6CMPkJXZGjie2unsiMzj3Ig=",
|
"narHash": "sha256-qwcDBtrRvJbrrnv1lf/pREQi8t2hWZxVAyeMo7/E9sw=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixos-hardware",
|
"repo": "nixos-hardware",
|
||||||
"rev": "740a22363033e9f1bb6270fbfb5a9574067af15b",
|
"rev": "41c6b421bdc301b2624486e11905c9af7b8ec68e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -296,11 +316,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1771903837,
|
"lastModified": 1772047000,
|
||||||
"narHash": "sha256-sdaqdnsQCv3iifzxwB22tUwN/fSHoN7j2myFW5EIkGk=",
|
"narHash": "sha256-7DaQVv4R97cii/Qdfy4tmDZMB2xxtyIvNGSwXBBhSmo=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "e764fc9a405871f1f6ca3d1394fb422e0a0c3951",
|
"rev": "1267bb4920d0fc06ea916734c11b0bf004bbe17e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -336,11 +356,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1770726378,
|
"lastModified": 1771858127,
|
||||||
"narHash": "sha256-kck+vIbGOaM/dHea7aTBxdFYpeUl/jHOy5W3eyRvVx8=",
|
"narHash": "sha256-Gtre9YoYl3n25tJH2AoSdjuwcqij5CPxL3U3xysYD08=",
|
||||||
"owner": "cachix",
|
"owner": "cachix",
|
||||||
"repo": "pre-commit-hooks.nix",
|
"repo": "pre-commit-hooks.nix",
|
||||||
"rev": "5eaaedde414f6eb1aea8b8525c466dc37bba95ae",
|
"rev": "49bbbfc218bf3856dfa631cead3b052d78248b83",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -352,6 +372,7 @@
|
|||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"agenix": "agenix",
|
"agenix": "agenix",
|
||||||
|
"arr-init": "arr-init",
|
||||||
"deploy-rs": "deploy-rs",
|
"deploy-rs": "deploy-rs",
|
||||||
"disko": "disko",
|
"disko": "disko",
|
||||||
"home-manager": "home-manager",
|
"home-manager": "home-manager",
|
||||||
@@ -376,11 +397,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1771125043,
|
"lastModified": 1771988922,
|
||||||
"narHash": "sha256-ldf/s49n6rOAxl7pYLJGGS1N/assoHkCOWdEdLyNZkc=",
|
"narHash": "sha256-Fc6FHXtfEkLtuVJzd0B6tFYMhmcPLuxr90rWfb/2jtQ=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "4912f951a26dc8142b176be2c2ad834319dc06e8",
|
"rev": "f4443dc3f0b6c5e6b77d923156943ce816d1fcb9",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -433,11 +454,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1771812348,
|
"lastModified": 1772071250,
|
||||||
"narHash": "sha256-d8LL7nSpFueYtZhK29t7j3JiaKLA4lqW8neJv/uZGQc=",
|
"narHash": "sha256-LDWvJDR1J8xE8TBJjzWnOA0oVP/l9xBFC4npQPJDHN4=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "srvos",
|
"repo": "srvos",
|
||||||
"rev": "ffc8fceb1e3cad06b5074cda30f88132b4fb4869",
|
"rev": "5cd73bcf984b72d8046e1175d13753de255adfb9",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -509,11 +530,11 @@
|
|||||||
"trackerlist": {
|
"trackerlist": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1771888186,
|
"lastModified": 1772233783,
|
||||||
"narHash": "sha256-CTaSxzIwkuhHl/gjvRbDJ3KZKaf2sZkay26aNeHOiBQ=",
|
"narHash": "sha256-2jPUBKpPuT4dCXwVFuZvTH3QyURixsfJZD7Zqs0atPY=",
|
||||||
"owner": "ngosang",
|
"owner": "ngosang",
|
||||||
"repo": "trackerslist",
|
"repo": "trackerslist",
|
||||||
"rev": "956a14978525f21b75ef4d1103226e70ae7f7896",
|
"rev": "85c4f103f130b070a192343c334f50c2f56b61a9",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
31
flake.nix
31
flake.nix
@@ -68,6 +68,11 @@
|
|||||||
ytbn-graphing-software = {
|
ytbn-graphing-software = {
|
||||||
url = "git+https://git.gardling.com/titaniumtown/YTBN-Graphing-Software";
|
url = "git+https://git.gardling.com/titaniumtown/YTBN-Graphing-Software";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
arr-init = {
|
||||||
|
url = "git+ssh://gitea@git.gardling.com/titaniumtown/arr-init";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
@@ -83,7 +88,7 @@
|
|||||||
srvos,
|
srvos,
|
||||||
deploy-rs,
|
deploy-rs,
|
||||||
impermanence,
|
impermanence,
|
||||||
agenix,
|
arr-init,
|
||||||
...
|
...
|
||||||
}@inputs:
|
}@inputs:
|
||||||
let
|
let
|
||||||
@@ -295,6 +300,8 @@
|
|||||||
|
|
||||||
lanzaboote.nixosModules.lanzaboote
|
lanzaboote.nixosModules.lanzaboote
|
||||||
|
|
||||||
|
arr-init.nixosModules.default
|
||||||
|
|
||||||
home-manager.nixosModules.home-manager
|
home-manager.nixosModules.home-manager
|
||||||
(
|
(
|
||||||
{
|
{
|
||||||
@@ -326,16 +333,16 @@
|
|||||||
checks.${system} = testSuite;
|
checks.${system} = testSuite;
|
||||||
|
|
||||||
packages.${system} = {
|
packages.${system} = {
|
||||||
tests = pkgs.linkFarm "all-tests" (
|
tests = pkgs.linkFarm "all-tests" (
|
||||||
pkgs.lib.mapAttrsToList (name: test: {
|
pkgs.lib.mapAttrsToList (name: test: {
|
||||||
name = name;
|
name = name;
|
||||||
path = test;
|
path = test;
|
||||||
}) testSuite
|
}) testSuite
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// (pkgs.lib.mapAttrs' (name: test: {
|
// (pkgs.lib.mapAttrs' (name: test: {
|
||||||
name = "test-${name}";
|
name = "test-${name}";
|
||||||
value = test;
|
value = test;
|
||||||
}) testSuite);
|
}) testSuite);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,497 +0,0 @@
|
|||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
cfg = config.services.arrInit;
|
|
||||||
bazarrCfg = config.services.bazarrInit;
|
|
||||||
|
|
||||||
downloadClientModule = lib.types.submodule {
|
|
||||||
options = {
|
|
||||||
name = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "Display name of the download client (e.g. \"qBittorrent\").";
|
|
||||||
example = "qBittorrent";
|
|
||||||
};
|
|
||||||
|
|
||||||
implementation = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "Implementation identifier for the Servarr API.";
|
|
||||||
example = "QBittorrent";
|
|
||||||
};
|
|
||||||
|
|
||||||
configContract = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "Config contract identifier for the Servarr API.";
|
|
||||||
example = "QBittorrentSettings";
|
|
||||||
};
|
|
||||||
|
|
||||||
protocol = lib.mkOption {
|
|
||||||
type = lib.types.enum [
|
|
||||||
"torrent"
|
|
||||||
"usenet"
|
|
||||||
];
|
|
||||||
default = "torrent";
|
|
||||||
description = "Download protocol type.";
|
|
||||||
};
|
|
||||||
|
|
||||||
fields = lib.mkOption {
|
|
||||||
type = lib.types.attrsOf lib.types.anything;
|
|
||||||
default = { };
|
|
||||||
description = ''
|
|
||||||
Flat key/value pairs for the download client configuration.
|
|
||||||
These are converted to the API's [{name, value}] array format.
|
|
||||||
'';
|
|
||||||
example = {
|
|
||||||
host = "192.168.15.1";
|
|
||||||
port = 6011;
|
|
||||||
useSsl = false;
|
|
||||||
tvCategory = "tvshows";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
syncedAppModule = lib.types.submodule {
|
|
||||||
options = {
|
|
||||||
name = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "Display name of the application to sync (e.g. \"Sonarr\").";
|
|
||||||
example = "Sonarr";
|
|
||||||
};
|
|
||||||
|
|
||||||
implementation = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "Implementation identifier for the Prowlarr application API.";
|
|
||||||
example = "Sonarr";
|
|
||||||
};
|
|
||||||
|
|
||||||
configContract = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "Config contract identifier for the Prowlarr application API.";
|
|
||||||
example = "SonarrSettings";
|
|
||||||
};
|
|
||||||
|
|
||||||
syncLevel = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "fullSync";
|
|
||||||
description = "Sync level for the application.";
|
|
||||||
};
|
|
||||||
|
|
||||||
prowlarrUrl = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "URL of the Prowlarr instance.";
|
|
||||||
example = "http://localhost:9696";
|
|
||||||
};
|
|
||||||
|
|
||||||
baseUrl = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "URL of the target application.";
|
|
||||||
example = "http://localhost:8989";
|
|
||||||
};
|
|
||||||
|
|
||||||
apiKeyFrom = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "Path to the config.xml file to read the API key from at runtime.";
|
|
||||||
example = "/services/sonarr/config.xml";
|
|
||||||
};
|
|
||||||
|
|
||||||
syncCategories = lib.mkOption {
|
|
||||||
type = lib.types.listOf lib.types.int;
|
|
||||||
default = [ ];
|
|
||||||
description = "List of sync category IDs for the application.";
|
|
||||||
example = [
|
|
||||||
5000
|
|
||||||
5010
|
|
||||||
5020
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
serviceName = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "Name of the systemd service to depend on for reading the API key.";
|
|
||||||
example = "sonarr";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
instanceModule = lib.types.submodule {
|
|
||||||
options = {
|
|
||||||
enable = lib.mkEnableOption "Servarr application API initialization";
|
|
||||||
|
|
||||||
serviceName = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "Name of the systemd service this init depends on.";
|
|
||||||
example = "sonarr";
|
|
||||||
};
|
|
||||||
|
|
||||||
dataDir = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "Path to the application data directory containing config.xml.";
|
|
||||||
example = "/var/lib/sonarr";
|
|
||||||
};
|
|
||||||
|
|
||||||
port = lib.mkOption {
|
|
||||||
type = lib.types.port;
|
|
||||||
description = "API port of the Servarr application.";
|
|
||||||
example = 8989;
|
|
||||||
};
|
|
||||||
|
|
||||||
apiVersion = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "v3";
|
|
||||||
description = "API version string used in the base URL.";
|
|
||||||
};
|
|
||||||
|
|
||||||
networkNamespacePath = lib.mkOption {
|
|
||||||
type = lib.types.nullOr lib.types.str;
|
|
||||||
default = null;
|
|
||||||
description = "If set, run this init service inside the given network namespace path (e.g. /run/netns/wg).";
|
|
||||||
};
|
|
||||||
|
|
||||||
downloadClients = lib.mkOption {
|
|
||||||
type = lib.types.listOf downloadClientModule;
|
|
||||||
default = [ ];
|
|
||||||
description = "List of download clients to configure via the API.";
|
|
||||||
};
|
|
||||||
|
|
||||||
rootFolders = lib.mkOption {
|
|
||||||
type = lib.types.listOf lib.types.str;
|
|
||||||
default = [ ];
|
|
||||||
description = "List of root folder paths to configure via the API.";
|
|
||||||
example = [
|
|
||||||
"/media/tv"
|
|
||||||
"/media/movies"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
syncedApps = lib.mkOption {
|
|
||||||
type = lib.types.listOf syncedAppModule;
|
|
||||||
default = [ ];
|
|
||||||
description = "Applications to register for indexer sync (Prowlarr only).";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
bazarrProviderModule = lib.types.submodule {
|
|
||||||
options = {
|
|
||||||
enable = lib.mkEnableOption "provider connection";
|
|
||||||
|
|
||||||
dataDir = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "Path to the provider's data directory containing config.xml.";
|
|
||||||
example = "/services/sonarr";
|
|
||||||
};
|
|
||||||
|
|
||||||
port = lib.mkOption {
|
|
||||||
type = lib.types.port;
|
|
||||||
description = "API port of the provider.";
|
|
||||||
example = 8989;
|
|
||||||
};
|
|
||||||
|
|
||||||
serviceName = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "Name of the systemd service to depend on.";
|
|
||||||
example = "sonarr";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
bazarrInitModule = lib.types.submodule {
|
|
||||||
options = {
|
|
||||||
enable = lib.mkEnableOption "Bazarr API initialization";
|
|
||||||
|
|
||||||
dataDir = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "Path to Bazarr's data directory containing config/config.ini.";
|
|
||||||
example = "/services/bazarr";
|
|
||||||
};
|
|
||||||
|
|
||||||
port = lib.mkOption {
|
|
||||||
type = lib.types.port;
|
|
||||||
default = 6767;
|
|
||||||
description = "API port of Bazarr.";
|
|
||||||
};
|
|
||||||
|
|
||||||
sonarr = lib.mkOption {
|
|
||||||
type = bazarrProviderModule;
|
|
||||||
default = {
|
|
||||||
enable = false;
|
|
||||||
};
|
|
||||||
description = "Sonarr provider configuration.";
|
|
||||||
};
|
|
||||||
|
|
||||||
radarr = lib.mkOption {
|
|
||||||
type = bazarrProviderModule;
|
|
||||||
default = {
|
|
||||||
enable = false;
|
|
||||||
};
|
|
||||||
description = "Radarr provider configuration.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
curl = "${pkgs.curl}/bin/curl";
|
|
||||||
jq = "${pkgs.jq}/bin/jq";
|
|
||||||
grep = "${pkgs.gnugrep}/bin/grep";
|
|
||||||
awk = "${pkgs.gawk}/bin/awk";
|
|
||||||
|
|
||||||
mkDownloadClientPayload =
|
|
||||||
dc:
|
|
||||||
builtins.toJSON {
|
|
||||||
enable = true;
|
|
||||||
protocol = dc.protocol;
|
|
||||||
priority = 1;
|
|
||||||
name = dc.name;
|
|
||||||
implementation = dc.implementation;
|
|
||||||
configContract = dc.configContract;
|
|
||||||
fields = lib.mapAttrsToList (n: v: {
|
|
||||||
name = n;
|
|
||||||
value = v;
|
|
||||||
}) dc.fields;
|
|
||||||
tags = [ ];
|
|
||||||
};
|
|
||||||
|
|
||||||
mkDownloadClientSection = dc: ''
|
|
||||||
# Download client: ${dc.name}
|
|
||||||
echo "Checking download client '${dc.name}'..."
|
|
||||||
EXISTING_DC=$(${curl} -sf "$BASE_URL/downloadclient" -H "X-Api-Key: $API_KEY")
|
|
||||||
if echo "$EXISTING_DC" | ${jq} -e --arg name ${lib.escapeShellArg dc.name} '.[] | select(.name == $name)' > /dev/null 2>&1; then
|
|
||||||
echo "Download client '${dc.name}' already exists, skipping"
|
|
||||||
else
|
|
||||||
echo "Adding download client '${dc.name}'..."
|
|
||||||
${curl} -sf -X POST "$BASE_URL/downloadclient?forceSave=true" \
|
|
||||||
-H "X-Api-Key: $API_KEY" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d ${lib.escapeShellArg (mkDownloadClientPayload dc)}
|
|
||||||
echo "Download client '${dc.name}' added"
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
|
|
||||||
mkRootFolderSection = path: ''
|
|
||||||
# Root folder: ${path}
|
|
||||||
echo "Checking root folder '${path}'..."
|
|
||||||
EXISTING_RF=$(${curl} -sf "$BASE_URL/rootfolder" -H "X-Api-Key: $API_KEY")
|
|
||||||
if echo "$EXISTING_RF" | ${jq} -e --arg path ${lib.escapeShellArg path} '.[] | select(.path == $path)' > /dev/null 2>&1; then
|
|
||||||
echo "Root folder '${path}' already exists, skipping"
|
|
||||||
else
|
|
||||||
echo "Adding root folder '${path}'..."
|
|
||||||
${curl} -sf -X POST "$BASE_URL/rootfolder" \
|
|
||||||
-H "X-Api-Key: $API_KEY" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d ${lib.escapeShellArg (builtins.toJSON { inherit path; })}
|
|
||||||
echo "Root folder '${path}' added"
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
|
|
||||||
mkSyncedAppSection = app: ''
|
|
||||||
# Synced app: ${app.name}
|
|
||||||
echo "Checking synced app '${app.name}'..."
|
|
||||||
TARGET_API_KEY=$(${grep} -oP '(?<=<ApiKey>)[^<]+' ${lib.escapeShellArg app.apiKeyFrom})
|
|
||||||
EXISTING_APPS=$(${curl} -sf "$BASE_URL/applications" -H "X-Api-Key: $API_KEY")
|
|
||||||
if echo "$EXISTING_APPS" | ${jq} -e --arg name ${lib.escapeShellArg app.name} '.[] | select(.name == $name)' > /dev/null 2>&1; then
|
|
||||||
echo "Synced app '${app.name}' already exists, skipping"
|
|
||||||
else
|
|
||||||
echo "Adding synced app '${app.name}'..."
|
|
||||||
PAYLOAD=$(${jq} -n \
|
|
||||||
--arg name ${lib.escapeShellArg app.name} \
|
|
||||||
--arg implementation ${lib.escapeShellArg app.implementation} \
|
|
||||||
--arg configContract ${lib.escapeShellArg app.configContract} \
|
|
||||||
--arg syncLevel ${lib.escapeShellArg app.syncLevel} \
|
|
||||||
--arg prowlarrUrl ${lib.escapeShellArg app.prowlarrUrl} \
|
|
||||||
--arg baseUrl ${lib.escapeShellArg app.baseUrl} \
|
|
||||||
--arg apiKey "$TARGET_API_KEY" \
|
|
||||||
--argjson syncCategories ${builtins.toJSON app.syncCategories} \
|
|
||||||
'{
|
|
||||||
name: $name,
|
|
||||||
implementation: $implementation,
|
|
||||||
configContract: $configContract,
|
|
||||||
syncLevel: $syncLevel,
|
|
||||||
fields: [
|
|
||||||
{name: "prowlarrUrl", value: $prowlarrUrl},
|
|
||||||
{name: "baseUrl", value: $baseUrl},
|
|
||||||
{name: "apiKey", value: $apiKey},
|
|
||||||
{name: "syncCategories", value: $syncCategories}
|
|
||||||
],
|
|
||||||
tags: []
|
|
||||||
}')
|
|
||||||
${curl} -sf -X POST "$BASE_URL/applications?forceSave=true" \
|
|
||||||
-H "X-Api-Key: $API_KEY" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "$PAYLOAD"
|
|
||||||
echo "Synced app '${app.name}' added"
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
|
|
||||||
mkInitScript =
|
|
||||||
name: inst:
|
|
||||||
pkgs.writeShellScript "${name}-init" ''
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
CONFIG_XML="${inst.dataDir}/config.xml"
|
|
||||||
|
|
||||||
if [ ! -f "$CONFIG_XML" ]; then
|
|
||||||
echo "Config file $CONFIG_XML not found, skipping ${name} init"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
API_KEY=$(${grep} -oP '(?<=<ApiKey>)[^<]+' "$CONFIG_XML")
|
|
||||||
BASE_URL="http://localhost:${builtins.toString inst.port}/api/${inst.apiVersion}"
|
|
||||||
|
|
||||||
# Wait for API to become available
|
|
||||||
echo "Waiting for ${name} API..."
|
|
||||||
for i in $(seq 1 90); do
|
|
||||||
if ${curl} -sf "$BASE_URL/system/status" -H "X-Api-Key: $API_KEY" > /dev/null 2>&1; then
|
|
||||||
echo "${name} API is ready"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
if [ "$i" -eq 90 ]; then
|
|
||||||
echo "${name} API not available after 90 seconds" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
${lib.concatMapStringsSep "\n" mkDownloadClientSection inst.downloadClients}
|
|
||||||
${lib.concatMapStringsSep "\n" mkRootFolderSection inst.rootFolders}
|
|
||||||
${lib.concatMapStringsSep "\n" mkSyncedAppSection inst.syncedApps}
|
|
||||||
|
|
||||||
echo "${name} init complete"
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Get list of service names that syncedApps depend on
|
|
||||||
getSyncedAppDeps = inst: map (app: "${app.serviceName}.service") inst.syncedApps;
|
|
||||||
|
|
||||||
enabledInstances = lib.filterAttrs (_: inst: inst.enable) cfg;
|
|
||||||
|
|
||||||
mkBazarrProviderSection =
|
|
||||||
type: provider:
|
|
||||||
let
|
|
||||||
ltype = lib.toLower type;
|
|
||||||
in
|
|
||||||
''
|
|
||||||
# ${type} provider
|
|
||||||
echo "Checking ${type} provider..."
|
|
||||||
PROVIDER_API_KEY=$(${grep} -oP '(?<=<ApiKey>)[^<]+' ${lib.escapeShellArg "${provider.dataDir}/config.xml"})
|
|
||||||
EXISTING=$(${curl} -sf "$BASE_URL/api/system/settings" -H "X-API-KEY: $API_KEY")
|
|
||||||
USE_FLAG=$(echo "$EXISTING" | ${jq} -r '.general.use_${ltype}')
|
|
||||||
EXISTING_KEY=$(echo "$EXISTING" | ${jq} -r '.${ltype}.apikey // ""')
|
|
||||||
if [ "$USE_FLAG" = "true" ] && [ -n "$EXISTING_KEY" ]; then
|
|
||||||
echo "${type} provider already configured, skipping"
|
|
||||||
else
|
|
||||||
echo "Adding ${type} provider..."
|
|
||||||
${curl} -sf -X POST "$BASE_URL/api/system/settings" \
|
|
||||||
-H "X-API-KEY: $API_KEY" \
|
|
||||||
-d "settings-general-use_${ltype}=true" \
|
|
||||||
-d "settings-${ltype}-ip=localhost" \
|
|
||||||
-d "settings-${ltype}-port=${builtins.toString provider.port}" \
|
|
||||||
-d "settings-${ltype}-apikey=$PROVIDER_API_KEY" \
|
|
||||||
-d "settings-${ltype}-ssl=false" \
|
|
||||||
-d "settings-${ltype}-base_url=/"
|
|
||||||
echo "${type} provider added"
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
|
|
||||||
mkBazarrInitScript = pkgs.writeShellScript "bazarr-init" ''
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
CONFIG_YAML="${bazarrCfg.dataDir}/config/config.yaml"
|
|
||||||
|
|
||||||
if [ ! -f "$CONFIG_YAML" ]; then
|
|
||||||
echo "Config file $CONFIG_YAML not found, skipping bazarr init"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
API_KEY=$(${awk} '/^auth:/{f=1} f && /apikey:/{gsub(/.*apikey: /, ""); print; exit}' "$CONFIG_YAML")
|
|
||||||
BASE_URL="http://localhost:${builtins.toString bazarrCfg.port}"
|
|
||||||
|
|
||||||
# Wait for API to become available
|
|
||||||
echo "Waiting for Bazarr API..."
|
|
||||||
for i in $(seq 1 90); do
|
|
||||||
if ${curl} -sf "$BASE_URL/api/system/status" -H "X-API-KEY: $API_KEY" > /dev/null 2>&1; then
|
|
||||||
echo "Bazarr API is ready"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
if [ "$i" -eq 90 ]; then
|
|
||||||
echo "Bazarr API not available after 90 seconds" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
${lib.optionalString bazarrCfg.sonarr.enable (mkBazarrProviderSection "Sonarr" bazarrCfg.sonarr)}
|
|
||||||
${lib.optionalString bazarrCfg.radarr.enable (mkBazarrProviderSection "Radarr" bazarrCfg.radarr)}
|
|
||||||
|
|
||||||
echo "Bazarr init complete"
|
|
||||||
'';
|
|
||||||
|
|
||||||
bazarrDeps = [
|
|
||||||
"bazarr.service"
|
|
||||||
]
|
|
||||||
++ (lib.optional bazarrCfg.sonarr.enable "${bazarrCfg.sonarr.serviceName}.service")
|
|
||||||
++ (lib.optional bazarrCfg.radarr.enable "${bazarrCfg.radarr.serviceName}.service");
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options.services.arrInit = lib.mkOption {
|
|
||||||
type = lib.types.attrsOf instanceModule;
|
|
||||||
default = { };
|
|
||||||
description = ''
|
|
||||||
Attribute set of Servarr application instances to initialize via their APIs.
|
|
||||||
Each instance generates a systemd oneshot service that idempotently configures
|
|
||||||
download clients, root folders, and synced applications.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
options.services.bazarrInit = lib.mkOption {
|
|
||||||
type = bazarrInitModule;
|
|
||||||
default = {
|
|
||||||
enable = false;
|
|
||||||
};
|
|
||||||
description = ''
|
|
||||||
Bazarr API initialization for connecting Sonarr and Radarr providers.
|
|
||||||
Bazarr uses a different API than Servarr applications, so it has its own module.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkMerge [
|
|
||||||
(lib.mkIf (enabledInstances != { }) {
|
|
||||||
systemd.services = lib.mapAttrs' (
|
|
||||||
name: inst:
|
|
||||||
lib.nameValuePair "${inst.serviceName}-init" {
|
|
||||||
description = "Initialize ${name} API connections";
|
|
||||||
after = [
|
|
||||||
"${inst.serviceName}.service"
|
|
||||||
]
|
|
||||||
++ (getSyncedAppDeps inst)
|
|
||||||
++ (lib.optional (inst.networkNamespacePath != null) "wg.service");
|
|
||||||
requires = [ "${inst.serviceName}.service" ];
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "oneshot";
|
|
||||||
RemainAfterExit = true;
|
|
||||||
ExecStart = "${mkInitScript name inst}";
|
|
||||||
}
|
|
||||||
// lib.optionalAttrs (inst.networkNamespacePath != null) {
|
|
||||||
NetworkNamespacePath = inst.networkNamespacePath;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
) enabledInstances;
|
|
||||||
})
|
|
||||||
|
|
||||||
(lib.mkIf bazarrCfg.enable {
|
|
||||||
systemd.services.bazarr-init = {
|
|
||||||
description = "Initialize Bazarr API connections";
|
|
||||||
after = bazarrDeps;
|
|
||||||
requires = bazarrDeps;
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "oneshot";
|
|
||||||
RemainAfterExit = true;
|
|
||||||
ExecStart = "${mkBazarrInitScript}";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
})
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -97,6 +97,11 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# TODO: sanoid's ExecStartPre runs `zfs allow` which blocks on TXG sync;
|
||||||
|
# on the hdds pool (slow spinning disks + large async frees) this causes
|
||||||
|
# 30+ minute hangs and guaranteed timeouts. Suppress until we fix sanoid
|
||||||
|
# to run as root without `zfs allow`. See: nixpkgs#72060, openzfs/zfs#14180
|
||||||
|
"sanoid".unitConfig.OnFailure = lib.mkForce "";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Global OnFailure drop-in for all services
|
# Global OnFailure drop-in for all services
|
||||||
@@ -105,6 +110,12 @@ in
|
|||||||
[Unit]
|
[Unit]
|
||||||
OnFailure=ntfy-alert@%p.service
|
OnFailure=ntfy-alert@%p.service
|
||||||
'')
|
'')
|
||||||
|
|
||||||
|
# Sanoid-specific drop-in to override the global OnFailure (see TODO above)
|
||||||
|
(pkgs.writeTextDir "etc/systemd/system/sanoid.service.d/onfailure.conf" ''
|
||||||
|
[Unit]
|
||||||
|
OnFailure=
|
||||||
|
'')
|
||||||
];
|
];
|
||||||
# ZED (ZFS Event Daemon) ntfy notification settings
|
# ZED (ZFS Event Daemon) ntfy notification settings
|
||||||
services.zfs.zed = {
|
services.zfs.zed = {
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ in
|
|||||||
yearly = 0;
|
yearly = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
datasets."${service_configs.zpool_ssds}/services/jellyfin_cache" = {
|
datasets."${service_configs.zpool_ssds}/services/jellyfin/cache" = {
|
||||||
recursive = true;
|
recursive = true;
|
||||||
autoprune = true;
|
autoprune = true;
|
||||||
autosnap = true;
|
autosnap = true;
|
||||||
|
|||||||
@@ -35,7 +35,38 @@
|
|||||||
let
|
let
|
||||||
heap_size = "4000M";
|
heap_size = "4000M";
|
||||||
in
|
in
|
||||||
"-Xmx${heap_size} -Xms${heap_size} -XX:+UseZGC -XX:+ZGenerational";
|
lib.concatStringsSep " " [
|
||||||
|
# Memory
|
||||||
|
"-Xmx${heap_size}"
|
||||||
|
"-Xms${heap_size}"
|
||||||
|
# GC
|
||||||
|
"-XX:+UseZGC"
|
||||||
|
"-XX:+ZGenerational"
|
||||||
|
# Base JVM optimizations (brucethemoose/Minecraft-Performance-Flags-Benchmarks)
|
||||||
|
"-XX:+UnlockExperimentalVMOptions"
|
||||||
|
"-XX:+UnlockDiagnosticVMOptions"
|
||||||
|
"-XX:+AlwaysActAsServerClassMachine"
|
||||||
|
"-XX:+AlwaysPreTouch"
|
||||||
|
"-XX:+DisableExplicitGC"
|
||||||
|
"-XX:+UseNUMA"
|
||||||
|
"-XX:+PerfDisableSharedMem"
|
||||||
|
"-XX:+UseFastUnorderedTimeStamps"
|
||||||
|
"-XX:+UseCriticalJavaThreadPriority"
|
||||||
|
"-XX:ThreadPriorityPolicy=1"
|
||||||
|
"-XX:AllocatePrefetchStyle=3"
|
||||||
|
"-XX:-DontCompileHugeMethods"
|
||||||
|
"-XX:MaxNodeLimit=240000"
|
||||||
|
"-XX:NodeLimitFudgeFactor=8000"
|
||||||
|
"-XX:ReservedCodeCacheSize=400M"
|
||||||
|
"-XX:NonNMethodCodeHeapSize=12M"
|
||||||
|
"-XX:ProfiledCodeHeapSize=194M"
|
||||||
|
"-XX:NonProfiledCodeHeapSize=194M"
|
||||||
|
"-XX:NmethodSweepActivity=1"
|
||||||
|
"-XX:+UseVectorCmov"
|
||||||
|
# Large pages (requires vm.nr_hugepages sysctl)
|
||||||
|
"-XX:+UseLargePages"
|
||||||
|
"-XX:LargePageSizeInBytes=2m"
|
||||||
|
];
|
||||||
|
|
||||||
serverProperties = {
|
serverProperties = {
|
||||||
server-port = service_configs.ports.minecraft;
|
server-port = service_configs.ports.minecraft;
|
||||||
@@ -87,8 +118,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
c2me = fetchurl {
|
c2me = fetchurl {
|
||||||
url = "https://cdn.modrinth.com/data/VSNURh3q/versions/DLKF3HZk/c2me-fabric-mc1.21.11-0.3.6%2Bbeta.1.0.jar";
|
url = "https://cdn.modrinth.com/data/VSNURh3q/versions/QdLiMUjx/c2me-fabric-mc1.21.11-0.3.7%2Balpha.0.7.jar";
|
||||||
sha512 = "d4f983aeb5083033b525522e623a9a9ba86b6fc9c83db008cc0575d0077e736ac9bee0b6b0e03b8d1c89ae27a4e5cdc269041f61eb0d1a10757de4c30b065467";
|
sha512 = "f9543febe2d649a82acd6d5b66189b6a3d820cf24aa503ba493fdb3bbd4e52e30912c4c763fe50006f9a46947ae8cd737d420838c61b93429542573ed67f958e";
|
||||||
};
|
};
|
||||||
|
|
||||||
krypton = fetchurl {
|
krypton = fetchurl {
|
||||||
@@ -110,12 +141,32 @@
|
|||||||
url = "https://cdn.modrinth.com/data/c7m1mi73/versions/CUh1DWeO/packetfixer-fabric-3.3.4-1.21.11.jar";
|
url = "https://cdn.modrinth.com/data/c7m1mi73/versions/CUh1DWeO/packetfixer-fabric-3.3.4-1.21.11.jar";
|
||||||
sha512 = "33331b16cb40c5e6fbaade3cacc26f3a0e8fa5805a7186f94d7366a0e14dbeee9de2d2e8c76fa71f5e9dd24eb1c261667c35447e32570ea965ca0f154fdfba0a";
|
sha512 = "33331b16cb40c5e6fbaade3cacc26f3a0e8fa5805a7186f94d7366a0e14dbeee9de2d2e8c76fa71f5e9dd24eb1c261667c35447e32570ea965ca0f154fdfba0a";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# fork of Modernfix for 1.21.11 (upstream will support 26.1)
|
||||||
|
modernfix = fetchurl {
|
||||||
|
url = "https://cdn.modrinth.com/data/TjSm1wrD/versions/JwSO8JCN/modernfix-5.25.2-build.4.jar";
|
||||||
|
sha512 = "0d65c05ac0475408c58ef54215714e6301113101bf98bfe4bb2ba949fbfddd98225ac4e2093a5f9206a9e01ba80a931424b237bdfa3b6e178c741ca6f7f8c6a3";
|
||||||
|
};
|
||||||
|
|
||||||
|
debugify = fetchurl {
|
||||||
|
url = "https://cdn.modrinth.com/data/QwxR6Gcd/versions/8Q49lnaU/debugify-1.21.11%2B1.0.jar";
|
||||||
|
sha512 = "04d82dd33f44ced37045f1f9a54ad4eacd70861ff74a8800f2d2df358579e6cb0ea86a34b0086b3e87026b1a0691dd6594b4fdc49f89106466eea840518beb03";
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.services.minecraft-server-main = {
|
||||||
|
serviceConfig = {
|
||||||
|
Nice = -5;
|
||||||
|
IOSchedulingPriority = 0;
|
||||||
|
LimitMEMLOCK = "infinity"; # Required for large pages
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
services.caddy.virtualHosts = lib.mkIf (config.services.caddy.enable) {
|
services.caddy.virtualHosts = lib.mkIf (config.services.caddy.enable) {
|
||||||
"map.${service_configs.https.domain}".extraConfig = ''
|
"map.${service_configs.https.domain}".extraConfig = ''
|
||||||
root * ${service_configs.minecraft.parent_dir}/${service_configs.minecraft.server_name}/squaremap/web
|
root * ${service_configs.minecraft.parent_dir}/${service_configs.minecraft.server_name}/squaremap/web
|
||||||
|
|||||||
@@ -1,419 +0,0 @@
|
|||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
testPkgs = pkgs.appendOverlays [ (import ../modules/overlays.nix) ];
|
|
||||||
in
|
|
||||||
testPkgs.testers.runNixOSTest {
|
|
||||||
name = "arr-init";
|
|
||||||
|
|
||||||
nodes.machine =
|
|
||||||
{ pkgs, ... }:
|
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
../modules/arr-init.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
system.stateVersion = config.system.stateVersion;
|
|
||||||
|
|
||||||
virtualisation.memorySize = 4096;
|
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
|
||||||
curl
|
|
||||||
jq
|
|
||||||
gnugrep
|
|
||||||
];
|
|
||||||
|
|
||||||
systemd.services.mock-qbittorrent =
|
|
||||||
let
|
|
||||||
mockQbitScript = pkgs.writeScript "mock-qbittorrent.py" ''
|
|
||||||
import json
|
|
||||||
from http.server import HTTPServer, BaseHTTPRequestHandler
|
|
||||||
from urllib.parse import parse_qs, urlparse
|
|
||||||
|
|
||||||
|
|
||||||
CATEGORIES = {
|
|
||||||
"tv": {"name": "tv", "savePath": "/downloads"},
|
|
||||||
"movies": {"name": "movies", "savePath": "/downloads"},
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class QBitMock(BaseHTTPRequestHandler):
|
|
||||||
def _respond(self, code=200, body=b"Ok.", content_type="text/plain"):
|
|
||||||
self.send_response(code)
|
|
||||||
self.send_header("Content-Type", content_type)
|
|
||||||
self.send_header("Set-Cookie", "SID=mock_session_id; Path=/")
|
|
||||||
self.end_headers()
|
|
||||||
self.wfile.write(body if isinstance(body, bytes) else body.encode())
|
|
||||||
|
|
||||||
def do_GET(self):
|
|
||||||
path = self.path.split("?")[0]
|
|
||||||
if path == "/api/v2/app/webapiVersion":
|
|
||||||
self._respond(body=b"2.9.3")
|
|
||||||
elif path == "/api/v2/app/version":
|
|
||||||
self._respond(body=b"v5.0.0")
|
|
||||||
elif path == "/api/v2/torrents/info":
|
|
||||||
self._respond(body=b"[]", content_type="application/json")
|
|
||||||
elif path == "/api/v2/torrents/categories":
|
|
||||||
body = json.dumps(CATEGORIES).encode()
|
|
||||||
self._respond(body=body, content_type="application/json")
|
|
||||||
elif path == "/api/v2/app/preferences":
|
|
||||||
body = json.dumps({"save_path": "/tmp"}).encode()
|
|
||||||
self._respond(body=body, content_type="application/json")
|
|
||||||
else:
|
|
||||||
self._respond()
|
|
||||||
|
|
||||||
def do_POST(self):
|
|
||||||
content_length = int(self.headers.get("Content-Length", 0))
|
|
||||||
body = self.rfile.read(content_length).decode()
|
|
||||||
path = urlparse(self.path).path
|
|
||||||
query = parse_qs(urlparse(self.path).query)
|
|
||||||
form = parse_qs(body)
|
|
||||||
params = {**query, **form}
|
|
||||||
if path == "/api/v2/torrents/createCategory":
|
|
||||||
name = params.get("category", [""])[0]
|
|
||||||
save_path = params.get("savePath", params.get("save_path", [""]))[0] or "/downloads"
|
|
||||||
if name:
|
|
||||||
CATEGORIES[name] = {"name": name, "savePath": save_path}
|
|
||||||
if path in ["/api/v2/torrents/editCategory", "/api/v2/torrents/removeCategory"]:
|
|
||||||
self._respond()
|
|
||||||
return
|
|
||||||
self._respond()
|
|
||||||
|
|
||||||
def log_message(self, format, *args):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
HTTPServer(("0.0.0.0", 6011), QBitMock).serve_forever()
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
{
|
|
||||||
description = "Mock qBittorrent API";
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
before = [
|
|
||||||
"sonarr-init.service"
|
|
||||||
"radarr-init.service"
|
|
||||||
];
|
|
||||||
serviceConfig = {
|
|
||||||
ExecStart = "${pkgs.python3}/bin/python3 ${mockQbitScript}";
|
|
||||||
Type = "simple";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.tmpfiles.rules = [
|
|
||||||
"d /media/tv 0755 sonarr sonarr -"
|
|
||||||
"d /media/movies 0755 radarr radarr -"
|
|
||||||
];
|
|
||||||
|
|
||||||
services.sonarr = {
|
|
||||||
enable = true;
|
|
||||||
dataDir = "/var/lib/sonarr/.config/NzbDrone";
|
|
||||||
settings.server.port = lib.mkDefault 8989;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.radarr = {
|
|
||||||
enable = true;
|
|
||||||
dataDir = "/var/lib/radarr/.config/Radarr";
|
|
||||||
settings.server.port = lib.mkDefault 7878;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.prowlarr = {
|
|
||||||
enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.bazarr = {
|
|
||||||
enable = true;
|
|
||||||
listenPort = 6767;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.arrInit.sonarr = {
|
|
||||||
enable = true;
|
|
||||||
serviceName = "sonarr";
|
|
||||||
dataDir = "/var/lib/sonarr/.config/NzbDrone";
|
|
||||||
port = 8989;
|
|
||||||
downloadClients = [
|
|
||||||
{
|
|
||||||
name = "qBittorrent";
|
|
||||||
implementation = "QBittorrent";
|
|
||||||
configContract = "QBittorrentSettings";
|
|
||||||
protocol = "torrent";
|
|
||||||
fields = {
|
|
||||||
host = "127.0.0.1";
|
|
||||||
port = 6011;
|
|
||||||
useSsl = false;
|
|
||||||
tvCategory = "tv";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
|
||||||
rootFolders = [ "/media/tv" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
services.arrInit.radarr = {
|
|
||||||
enable = true;
|
|
||||||
serviceName = "radarr";
|
|
||||||
dataDir = "/var/lib/radarr/.config/Radarr";
|
|
||||||
port = 7878;
|
|
||||||
downloadClients = [
|
|
||||||
{
|
|
||||||
name = "qBittorrent";
|
|
||||||
implementation = "QBittorrent";
|
|
||||||
configContract = "QBittorrentSettings";
|
|
||||||
protocol = "torrent";
|
|
||||||
fields = {
|
|
||||||
host = "127.0.0.1";
|
|
||||||
port = 6011;
|
|
||||||
useSsl = false;
|
|
||||||
movieCategory = "movies";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
|
||||||
rootFolders = [ "/media/movies" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
services.arrInit.prowlarr = {
|
|
||||||
enable = true;
|
|
||||||
serviceName = "prowlarr";
|
|
||||||
dataDir = "/var/lib/prowlarr";
|
|
||||||
port = 9696;
|
|
||||||
apiVersion = "v1";
|
|
||||||
syncedApps = [
|
|
||||||
{
|
|
||||||
name = "Sonarr";
|
|
||||||
implementation = "Sonarr";
|
|
||||||
configContract = "SonarrSettings";
|
|
||||||
prowlarrUrl = "http://localhost:9696";
|
|
||||||
baseUrl = "http://localhost:8989";
|
|
||||||
apiKeyFrom = "/var/lib/sonarr/.config/NzbDrone/config.xml";
|
|
||||||
syncCategories = [
|
|
||||||
5000
|
|
||||||
5010
|
|
||||||
5020
|
|
||||||
5030
|
|
||||||
5040
|
|
||||||
5045
|
|
||||||
5050
|
|
||||||
5090
|
|
||||||
];
|
|
||||||
serviceName = "sonarr";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
name = "Radarr";
|
|
||||||
implementation = "Radarr";
|
|
||||||
configContract = "RadarrSettings";
|
|
||||||
prowlarrUrl = "http://localhost:9696";
|
|
||||||
baseUrl = "http://localhost:7878";
|
|
||||||
apiKeyFrom = "/var/lib/radarr/.config/Radarr/config.xml";
|
|
||||||
syncCategories = [
|
|
||||||
2000
|
|
||||||
2010
|
|
||||||
2020
|
|
||||||
2030
|
|
||||||
2040
|
|
||||||
2045
|
|
||||||
2050
|
|
||||||
2060
|
|
||||||
2070
|
|
||||||
2080
|
|
||||||
];
|
|
||||||
serviceName = "radarr";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
services.bazarrInit = {
|
|
||||||
enable = true;
|
|
||||||
dataDir = "/var/lib/bazarr";
|
|
||||||
port = 6767;
|
|
||||||
sonarr = {
|
|
||||||
enable = true;
|
|
||||||
dataDir = "/var/lib/sonarr/.config/NzbDrone";
|
|
||||||
port = 8989;
|
|
||||||
serviceName = "sonarr";
|
|
||||||
};
|
|
||||||
radarr = {
|
|
||||||
enable = true;
|
|
||||||
dataDir = "/var/lib/radarr/.config/Radarr";
|
|
||||||
port = 7878;
|
|
||||||
serviceName = "radarr";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
testScript = ''
|
|
||||||
start_all()
|
|
||||||
|
|
||||||
# Wait for services to start
|
|
||||||
machine.wait_for_unit("mock-qbittorrent.service")
|
|
||||||
machine.wait_until_succeeds("curl -sf http://localhost:6011/api/v2/app/version", timeout=30)
|
|
||||||
machine.wait_for_unit("sonarr.service")
|
|
||||||
machine.wait_for_unit("radarr.service")
|
|
||||||
machine.wait_for_unit("prowlarr.service")
|
|
||||||
machine.wait_for_unit("bazarr.service")
|
|
||||||
|
|
||||||
# Wait for Sonarr API to be ready (config.xml is auto-generated on first start)
|
|
||||||
machine.wait_until_succeeds(
|
|
||||||
"API_KEY=$(grep -oP '(?<=<ApiKey>)[^<]+' /var/lib/sonarr/.config/NzbDrone/config.xml) && "
|
|
||||||
"curl -sf http://localhost:8989/api/v3/system/status -H \"X-Api-Key: $API_KEY\"",
|
|
||||||
timeout=120,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Wait for Radarr API to be ready
|
|
||||||
machine.wait_until_succeeds(
|
|
||||||
"API_KEY=$(grep -oP '(?<=<ApiKey>)[^<]+' /var/lib/radarr/.config/Radarr/config.xml) && "
|
|
||||||
"curl -sf http://localhost:7878/api/v3/system/status -H \"X-Api-Key: $API_KEY\"",
|
|
||||||
timeout=120,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Wait for Prowlarr API to be ready
|
|
||||||
machine.wait_until_succeeds(
|
|
||||||
"API_KEY=$(grep -oP '(?<=<ApiKey>)[^<]+' /var/lib/prowlarr/config.xml) && "
|
|
||||||
"curl -sf http://localhost:9696/api/v1/system/status -H \"X-Api-Key: $API_KEY\"",
|
|
||||||
timeout=180,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Ensure init services run after config.xml exists
|
|
||||||
machine.succeed("systemctl restart sonarr-init.service")
|
|
||||||
machine.succeed("systemctl restart radarr-init.service")
|
|
||||||
machine.wait_for_unit("sonarr-init.service")
|
|
||||||
machine.wait_for_unit("radarr-init.service")
|
|
||||||
|
|
||||||
# Wait for init services to complete
|
|
||||||
machine.wait_for_unit("sonarr-init.service")
|
|
||||||
machine.wait_for_unit("radarr-init.service")
|
|
||||||
|
|
||||||
# Verify Sonarr download clients
|
|
||||||
machine.succeed(
|
|
||||||
"API_KEY=$(grep -oP '(?<=<ApiKey>)[^<]+' /var/lib/sonarr/.config/NzbDrone/config.xml) && "
|
|
||||||
"curl -sf http://localhost:8989/api/v3/downloadclient -H \"X-Api-Key: $API_KEY\" | "
|
|
||||||
"jq -e '.[] | select(.name == \"qBittorrent\")'"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Verify Sonarr root folders
|
|
||||||
machine.succeed(
|
|
||||||
"API_KEY=$(grep -oP '(?<=<ApiKey>)[^<]+' /var/lib/sonarr/.config/NzbDrone/config.xml) && "
|
|
||||||
"curl -sf http://localhost:8989/api/v3/rootfolder -H \"X-Api-Key: $API_KEY\" | "
|
|
||||||
"jq -e '.[] | select(.path == \"/media/tv\")'"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Verify Radarr download clients
|
|
||||||
machine.succeed(
|
|
||||||
"API_KEY=$(grep -oP '(?<=<ApiKey>)[^<]+' /var/lib/radarr/.config/Radarr/config.xml) && "
|
|
||||||
"curl -sf http://localhost:7878/api/v3/downloadclient -H \"X-Api-Key: $API_KEY\" | "
|
|
||||||
"jq -e '.[] | select(.name == \"qBittorrent\")'"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Verify Radarr root folders
|
|
||||||
machine.succeed(
|
|
||||||
"API_KEY=$(grep -oP '(?<=<ApiKey>)[^<]+' /var/lib/radarr/.config/Radarr/config.xml) && "
|
|
||||||
"curl -sf http://localhost:7878/api/v3/rootfolder -H \"X-Api-Key: $API_KEY\" | "
|
|
||||||
"jq -e '.[] | select(.path == \"/media/movies\")'"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Restart prowlarr-init now that all config.xml files exist
|
|
||||||
machine.succeed("systemctl restart prowlarr-init.service")
|
|
||||||
machine.wait_for_unit("prowlarr-init.service")
|
|
||||||
|
|
||||||
# Verify Sonarr registered as synced app in Prowlarr
|
|
||||||
machine.succeed(
|
|
||||||
"API_KEY=$(grep -oP '(?<=<ApiKey>)[^<]+' /var/lib/prowlarr/config.xml) && "
|
|
||||||
"curl -sf http://localhost:9696/api/v1/applications -H \"X-Api-Key: $API_KEY\" | "
|
|
||||||
"jq -e '.[] | select(.name == \"Sonarr\")'"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Verify Radarr registered as synced app in Prowlarr
|
|
||||||
machine.succeed(
|
|
||||||
"API_KEY=$(grep -oP '(?<=<ApiKey>)[^<]+' /var/lib/prowlarr/config.xml) && "
|
|
||||||
"curl -sf http://localhost:9696/api/v1/applications -H \"X-Api-Key: $API_KEY\" | "
|
|
||||||
"jq -e '.[] | select(.name == \"Radarr\")'"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Idempotency test: restart init services and verify no duplicate entries
|
|
||||||
machine.succeed("systemctl restart sonarr-init.service")
|
|
||||||
machine.succeed("systemctl restart radarr-init.service")
|
|
||||||
machine.succeed("systemctl restart prowlarr-init.service")
|
|
||||||
|
|
||||||
# Verify Sonarr still has exactly 1 download client
|
|
||||||
result = machine.succeed(
|
|
||||||
"API_KEY=$(grep -oP '(?<=<ApiKey>)[^<]+' /var/lib/sonarr/.config/NzbDrone/config.xml) && "
|
|
||||||
"curl -sf http://localhost:8989/api/v3/downloadclient -H \"X-Api-Key: $API_KEY\" | "
|
|
||||||
"jq '. | length'"
|
|
||||||
).strip()
|
|
||||||
assert result == "1", f"Expected 1 Sonarr download client, got {result}"
|
|
||||||
|
|
||||||
# Verify Sonarr still has exactly 1 root folder
|
|
||||||
result = machine.succeed(
|
|
||||||
"API_KEY=$(grep -oP '(?<=<ApiKey>)[^<]+' /var/lib/sonarr/.config/NzbDrone/config.xml) && "
|
|
||||||
"curl -sf http://localhost:8989/api/v3/rootfolder -H \"X-Api-Key: $API_KEY\" | "
|
|
||||||
"jq '. | length'"
|
|
||||||
).strip()
|
|
||||||
assert result == "1", f"Expected 1 Sonarr root folder, got {result}"
|
|
||||||
|
|
||||||
# Verify Radarr still has exactly 1 download client
|
|
||||||
result = machine.succeed(
|
|
||||||
"API_KEY=$(grep -oP '(?<=<ApiKey>)[^<]+' /var/lib/radarr/.config/Radarr/config.xml) && "
|
|
||||||
"curl -sf http://localhost:7878/api/v3/downloadclient -H \"X-Api-Key: $API_KEY\" | "
|
|
||||||
"jq '. | length'"
|
|
||||||
).strip()
|
|
||||||
assert result == "1", f"Expected 1 Radarr download client, got {result}"
|
|
||||||
|
|
||||||
# Verify Radarr still has exactly 1 root folder
|
|
||||||
result = machine.succeed(
|
|
||||||
"API_KEY=$(grep -oP '(?<=<ApiKey>)[^<]+' /var/lib/radarr/.config/Radarr/config.xml) && "
|
|
||||||
"curl -sf http://localhost:7878/api/v3/rootfolder -H \"X-Api-Key: $API_KEY\" | "
|
|
||||||
"jq '. | length'"
|
|
||||||
).strip()
|
|
||||||
assert result == "1", f"Expected 1 Radarr root folder, got {result}"
|
|
||||||
|
|
||||||
# Verify Prowlarr still has exactly 2 synced apps
|
|
||||||
result = machine.succeed(
|
|
||||||
"API_KEY=$(grep -oP '(?<=<ApiKey>)[^<]+' /var/lib/prowlarr/config.xml) && "
|
|
||||||
"curl -sf http://localhost:9696/api/v1/applications -H \"X-Api-Key: $API_KEY\" | "
|
|
||||||
"jq '. | length'"
|
|
||||||
).strip()
|
|
||||||
assert result == "2", f"Expected 2 Prowlarr synced apps, got {result}"
|
|
||||||
|
|
||||||
# Wait for Bazarr to generate config.yaml
|
|
||||||
machine.wait_until_succeeds(
|
|
||||||
"test -f /var/lib/bazarr/config/config.yaml",
|
|
||||||
timeout=120,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Wait for Bazarr API to be ready
|
|
||||||
machine.wait_until_succeeds(
|
|
||||||
"API_KEY=$(awk '/^auth:/{f=1} f && /apikey:/{gsub(/.*apikey: /, \"\"); print; exit}' /var/lib/bazarr/config/config.yaml) && "
|
|
||||||
"curl -sf http://localhost:6767/api/system/status -H \"X-API-KEY: $API_KEY\"",
|
|
||||||
timeout=120,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Restart bazarr-init now that config.yaml exists
|
|
||||||
machine.succeed("systemctl restart bazarr-init.service")
|
|
||||||
machine.wait_for_unit("bazarr-init.service")
|
|
||||||
|
|
||||||
# Verify Sonarr provider configured in Bazarr
|
|
||||||
machine.succeed(
|
|
||||||
"API_KEY=$(awk '/^auth:/{f=1} f && /apikey:/{gsub(/.*apikey: /, \"\"); print; exit}' /var/lib/bazarr/config/config.yaml) && "
|
|
||||||
"curl -sf http://localhost:6767/api/system/settings -H \"X-API-KEY: $API_KEY\" | "
|
|
||||||
"jq -e '.general.use_sonarr == true and (.sonarr.apikey // \"\") != \"\"'"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Verify Radarr provider configured in Bazarr
|
|
||||||
machine.succeed(
|
|
||||||
"API_KEY=$(awk '/^auth:/{f=1} f && /apikey:/{gsub(/.*apikey: /, \"\"); print; exit}' /var/lib/bazarr/config/config.yaml) && "
|
|
||||||
"curl -sf http://localhost:6767/api/system/settings -H \"X-API-KEY: $API_KEY\" | "
|
|
||||||
"jq -e '.general.use_radarr == true and (.radarr.apikey // \"\") != \"\"'"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Idempotency: restart bazarr-init and verify no duplicate config
|
|
||||||
machine.succeed("systemctl restart bazarr-init.service")
|
|
||||||
machine.wait_for_unit("bazarr-init.service")
|
|
||||||
|
|
||||||
machine.succeed(
|
|
||||||
"API_KEY=$(awk '/^auth:/{f=1} f && /apikey:/{gsub(/.*apikey: /, \"\"); print; exit}' /var/lib/bazarr/config/config.yaml) && "
|
|
||||||
"curl -sf http://localhost:6767/api/system/settings -H \"X-API-KEY: $API_KEY\" | "
|
|
||||||
"jq -e '.general.use_sonarr == true and (.sonarr.apikey // \"\") != \"\"'"
|
|
||||||
)
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
@@ -60,6 +60,10 @@ testPkgs.testers.runNixOSTest {
|
|||||||
wants = lib.mkForce [ ];
|
wants = lib.mkForce [ ];
|
||||||
after = lib.mkForce [ ];
|
after = lib.mkForce [ ];
|
||||||
requires = lib.mkForce [ ];
|
requires = lib.mkForce [ ];
|
||||||
|
serviceConfig = {
|
||||||
|
Nice = lib.mkForce 0;
|
||||||
|
LimitMEMLOCK = lib.mkForce "infinity";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Test-specific overrides only - reduce memory for testing
|
# Test-specific overrides only - reduce memory for testing
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ in
|
|||||||
fail2banImmichTest = handleTest ./fail2ban-immich.nix;
|
fail2banImmichTest = handleTest ./fail2ban-immich.nix;
|
||||||
fail2banJellyfinTest = handleTest ./fail2ban-jellyfin.nix;
|
fail2banJellyfinTest = handleTest ./fail2ban-jellyfin.nix;
|
||||||
|
|
||||||
# arr tests
|
|
||||||
arrInitTest = handleTest ./arr-init.nix;
|
|
||||||
# ntfy alerts test
|
# ntfy alerts test
|
||||||
ntfyAlertsTest = handleTest ./ntfy-alerts.nix;
|
ntfyAlertsTest = handleTest ./ntfy-alerts.nix;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user