Because Maintainerr rules are complex, the recommended workflow is to design them in the Maintainerr UI first, then export the JSON via the API and declare them in your Nix configuration.
Workflow
- Enable Maintainerr: Ensure the service is running.
- Design in UI: Open the Maintainerr UI and create rule groups on the Rules page. Configure libraries, data types, collection settings, and rule conditions.
- Retrieve JSON: Use the API to get the resulting configuration:
curl -s http://localhost:6246/api/rules | jq .
- Convert to Nix: Convert the JSON to a Nix attribute set and add it to
nixflix.maintainerr.rules. - Rebuild: The
maintainerr-rules service will sync the state, creating or updating declared groups and deleting those no longer listed.
Field Mapping & Conversion Notes
When converting API JSON to Nix, note these specific mapping requirements:
library: Use the human-readable title (e.g., "Movies") instead of the libraryId GUID. The service resolves this via GET /api/media-server/libraries.radarrServerName / sonarrServerName: Use the server name as configured in nixflix.maintainerr.settings.radarr or nixflix.maintainerr.settings.sonarr (e.g., "Radarr", "Sonarr Anime"), not the integer ID.arrAction: Map this from collection.arrAction in the API response.listExclusions / forceSeerr: Map these from collection.listExclusions and collection.forceSeerr.rules: The API returns a ruleJson string for each rule. You must parse this string and use its fields directly in your Nix list.
To easily inspect the parsed rule logic, use this command:
curl -s http://localhost:6246/api/rules | jq '.[0].rules[].ruleJson | fromjson'
nixflix.maintainerr.rules = [
{
name = "Movies To Delete";
description = "Deletes movies that have been watched or have been around for too long.";
library = "Movies";
dataType = "movie";
radarrServerName = "Radarr";
collection = {
deleteAfterDays = 14;
overlayEnabled = true;
};
rules = [
{
customVal = { ruleTypeId = 3; value = "1"; };
firstVal = [ 6 42 ];
action = 2;
section = 0;
}
];
}
];