nixos/modules/services/beesd.nix

60 lines
1.8 KiB
Nix
Raw Normal View History

2023-09-28 23:35:25 +08:00
inputs:
{
2024-03-24 18:19:58 +08:00
options.nixos.services.beesd = let inherit (inputs.lib) mkOption types; in mkOption
2023-09-28 23:35:25 +08:00
{
2024-03-24 18:19:58 +08:00
type = types.nullOr (types.submodule { options =
2023-09-29 10:21:49 +08:00
{
2024-03-24 18:19:58 +08:00
instances = mkOption
2023-09-28 23:35:25 +08:00
{
2024-03-24 18:19:58 +08:00
type = types.attrsOf (types.oneOf
[
types.nonEmptyStr
(types.submodule (submoduleInputs:
2023-09-29 09:38:44 +08:00
{
2024-03-24 18:19:58 +08:00
options =
2023-09-29 09:38:44 +08:00
{
2024-03-24 18:19:58 +08:00
device = mkOption { type = types.nonEmptyStr; };
hashTableSizeMB = mkOption { type = types.ints.unsigned; default = 1024; };
threads = mkOption { type = types.ints.unsigned; default = 1; };
loadAverage = mkOption { type = types.ints.unsigned; default = submoduleInputs.config.threads; };
};
}))
2024-03-24 18:19:58 +08:00
]);
default = {};
};
};});
default = null;
};
config = let inherit (inputs.config.nixos.services) beesd; in inputs.lib.mkIf (beesd != null)
{
services.beesd.filesystems = builtins.listToAttrs (map
(instance:
{
inherit (instance) name;
value =
2023-09-29 01:02:39 +08:00
{
2024-03-24 18:19:58 +08:00
spec = instance.value.device or instance.value;
hashTableSizeMB = instance.value.hashTableSizeMB or 1024;
extraOptions =
[
"--workaround-btrfs-send"
"--thread-count" "${builtins.toString instance.value.threads or 1}"
"--loadavg-target" "${builtins.toString instance.value.loadAverage or 1}"
2024-03-24 18:19:58 +08:00
"--scan-mode" "3"
2024-07-20 09:00:50 +08:00
"--verbose" "6"
2024-03-24 18:19:58 +08:00
];
2023-09-29 01:02:39 +08:00
};
2024-03-24 18:19:58 +08:00
})
(inputs.localLib.attrsToList beesd.instances));
systemd.slices.system-beesd.sliceConfig =
{
CPUSchedulingPolicy = "idle";
IOSchedulingClass = "idle";
IOSchedulingPriority = 4;
IOAccounting = true;
IOWeight = 1;
Nice = 19;
};
};
2023-09-28 23:35:25 +08:00
}