nixos/unpackerr: init module

This commit is contained in:
Wekuz
2026-06-02 23:52:15 +03:00
parent 6cb1c5ef54
commit c87d6f2efe
5 changed files with 145 additions and 0 deletions
@@ -164,6 +164,8 @@
- [LogiOps](https://github.com/PixlOne/logiops), a unofficial userspace driver for HID++ Logitech devices. Available as [services.logiops](#opt-services.logiops.enable).
- [Unpackerr](https://unpackerr.zip), extracts downloads for Radarr, Sonarr, Lidarr, Readarr, and/or a Watch folder. Available as [services.unpackerr](#opt-services.unpackerr.enable).
## Backward Incompatibilities {#sec-release-26.05-incompatibilities}
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
+1
View File
@@ -993,6 +993,7 @@
./services/misc/tuxclocker.nix
./services/misc/tzupdate.nix
./services/misc/uhub.nix
./services/misc/unpackerr.nix
./services/misc/wastebin.nix
./services/misc/weechat.nix
./services/misc/workout-tracker.nix
+102
View File
@@ -0,0 +1,102 @@
{
config,
pkgs,
lib,
utils,
...
}:
let
cfg = config.services.unpackerr;
configFormat = pkgs.formats.toml { };
configFile = configFormat.generate "unpackerr.conf" cfg.settings;
inherit (lib)
mkEnableOption
mkOption
mkPackageOption
mkIf
getExe
types
;
in
{
options = {
services.unpackerr = {
enable = mkEnableOption "Unpackerr";
settings = mkOption {
type = configFormat.type;
default = { };
example = {
radarr = [
{
url = "http://127.0.0.1:8989";
api_key = "0123456789abcdef0123456789abcdef";
}
];
sonarr = [
{
url = "http://127.0.0.1:7878";
api_key = "0123456789abcdef0123456789abcdef";
}
];
};
description = ''
Unpackerr TOML configuration as a Nix attribute set.
Refer to [Unpackerr docs](https://unpackerr.zip/docs/install/configuration) for details.
For setting secrets refer to this [section](https://unpackerr.zip/docs/install/configuration/#secrets-and-passwords).
'';
};
user = mkOption {
type = types.str;
default = "unpackerr";
description = "User account under which Unpackerr runs.";
};
group = mkOption {
type = types.str;
default = "unpackerr";
description = "Group under which Unpackerr runs.";
};
package = mkPackageOption pkgs "unpackerr" { };
};
};
config = mkIf cfg.enable {
# Upstream service: https://github.com/Unpackerr/unpackerr/blob/main/init/systemd/unpackerr.service
systemd = {
services.unpackerr = {
description = "Unpackerr - archive extraction daemon";
wants = [ "network.target" ];
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "exec";
User = cfg.user;
Group = cfg.group;
ExecStart = utils.escapeSystemdExecArgs [
(getExe cfg.package)
"--config=${configFile}"
];
Restart = "always";
RestartSec = 10;
};
};
};
users.users = mkIf (cfg.user == "unpackerr") {
unpackerr = {
inherit (cfg) group;
isSystemUser = true;
};
};
users.groups = mkIf (cfg.group == "unpackerr") {
unpackerr = { };
};
};
meta.maintainers = with lib.maintainers; [ Wekuz ];
}
+1
View File
@@ -1737,6 +1737,7 @@ in
unifi = runTest ./unifi.nix;
unit-perl = runTest ./web-servers/unit-perl.nix;
unit-php = runTest ./web-servers/unit-php.nix;
unpackerr = runTest ./unpackerr.nix;
upnp.iptables = handleTest ./upnp.nix { useNftables = false; };
upnp.nftables = handleTest ./upnp.nix { useNftables = true; };
uptermd = runTest ./uptermd.nix;
+39
View File
@@ -0,0 +1,39 @@
{ lib, ... }:
{
name = "unpackerr";
meta.maintainers = with lib.maintainers; [ Wekuz ];
nodes.machine =
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [ zip ];
systemd.tmpfiles.settings."10-unpackerr"."/srv/unpackerr".d = {
mode = "0775";
user = "unpackerr";
group = "users";
};
services.unpackerr = {
enable = true;
group = "users";
settings = {
start_delay = "15s";
folder = [
{
path = "/srv/unpackerr";
}
];
};
};
};
testScript = ''
machine.wait_for_unit("unpackerr.service")
machine.wait_until_succeeds("journalctl -u unpackerr.service --grep '\\[Folder\\] Watching \\(fsnotify\\)'", timeout=60)
machine.succeed("echo unpackerr-test > /tmp/file.txt && cd /tmp && zip /srv/unpackerr/test.zip ./file.txt && rm ./file.txt")
machine.wait_until_succeeds("[[ -d /srv/unpackerr/test ]]", timeout=120)
machine.succeed("""[[ 'unpackerr-test' == "$(< /srv/unpackerr/test/file.txt)" ]]""")
'';
}