2023-09-28 23:35:25 +08:00
|
|
|
inputs:
|
|
|
|
{
|
|
|
|
options.nixos.services.beesd = let inherit (inputs.lib) mkOption types; in
|
|
|
|
{
|
|
|
|
enable = mkOption { type = types.bool; default = false; };
|
2023-09-29 10:21:49 +08:00
|
|
|
instances = mkOption
|
|
|
|
{
|
|
|
|
type = types.attrsOf (types.oneOf
|
|
|
|
[
|
|
|
|
types.nonEmptyStr
|
|
|
|
(types.submodule { options =
|
|
|
|
{
|
|
|
|
device = mkOption { type = types.nonEmptyStr; };
|
2023-09-29 18:33:35 +08:00
|
|
|
hashTableSizeMB = mkOption { type = types.int; };
|
2023-09-29 10:21:49 +08:00
|
|
|
};})
|
|
|
|
]);
|
|
|
|
default = {};
|
|
|
|
};
|
2023-09-28 23:35:25 +08:00
|
|
|
};
|
|
|
|
config =
|
|
|
|
let
|
|
|
|
inherit (inputs.config.nixos.services) beesd;
|
|
|
|
inherit (inputs.lib) mkIf;
|
|
|
|
inherit (builtins) map listToAttrs;
|
|
|
|
inherit (inputs.localLib) attrsToList;
|
|
|
|
in mkIf beesd.enable
|
|
|
|
{
|
|
|
|
services.beesd.filesystems = listToAttrs (map
|
2023-09-29 09:38:44 +08:00
|
|
|
(instance:
|
|
|
|
{
|
|
|
|
inherit (instance) name;
|
|
|
|
value =
|
|
|
|
{
|
2023-09-29 10:21:49 +08:00
|
|
|
spec = instance.value.device or instance.value;
|
|
|
|
hashTableSizeMB = instance.value.hashTableSizeMB or 1024;
|
2023-09-29 09:38:44 +08:00
|
|
|
extraOptions = [ "--thread-count" "1" ];
|
|
|
|
};
|
|
|
|
})
|
2023-09-28 23:35:25 +08:00
|
|
|
(attrsToList beesd.instances));
|
2023-09-29 01:02:39 +08:00
|
|
|
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
|
|
|
};
|
|
|
|
}
|