mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-24 06:33:42 +00:00
fc8f58848e
- use utils.escapeSystemdExecArgs in systemd service - remove StandardError="journal" as it's already default
117 lines
3.0 KiB
Nix
117 lines
3.0 KiB
Nix
{
|
|
lib,
|
|
pkgs,
|
|
config,
|
|
utils,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.services.scx;
|
|
in
|
|
{
|
|
options.services.scx = {
|
|
enable = lib.mkEnableOption null // {
|
|
description = ''
|
|
Whether to enable SCX service, a daemon to run schedulers from userspace.
|
|
|
|
::: {.note}
|
|
This service requires a kernel with the Sched-ext feature.
|
|
Generally, kernel version 6.12 and later are supported.
|
|
:::
|
|
'';
|
|
};
|
|
|
|
package = lib.mkOption {
|
|
type = lib.types.package;
|
|
default = pkgs.scx.full;
|
|
defaultText = lib.literalExpression "pkgs.scx.full";
|
|
example = lib.literalExpression "pkgs.scx.rustscheds";
|
|
description = ''
|
|
`scx` package to use. `scx.full`, which includes all schedulers, is the default.
|
|
You may choose a minimal package, such as `pkgs.scx.rustscheds`.
|
|
|
|
::: {.note}
|
|
Overriding this does not change the default scheduler; you should set `services.scx.scheduler` for it.
|
|
:::
|
|
'';
|
|
};
|
|
|
|
scheduler = lib.mkOption {
|
|
type = lib.types.enum [
|
|
"scx_bpfland"
|
|
"scx_central"
|
|
"scx_flatcg"
|
|
"scx_lavd"
|
|
"scx_layered"
|
|
"scx_nest"
|
|
"scx_pair"
|
|
"scx_qmap"
|
|
"scx_rlfifo"
|
|
"scx_rustland"
|
|
"scx_rusty"
|
|
"scx_simple"
|
|
"scx_userland"
|
|
];
|
|
default = "scx_rustland";
|
|
example = "scx_bpfland";
|
|
description = ''
|
|
Which scheduler to use. See [SCX documentation](https://github.com/sched-ext/scx/tree/main/scheds)
|
|
for details on each scheduler and guidance on selecting the most suitable one.
|
|
'';
|
|
};
|
|
|
|
extraArgs = lib.mkOption {
|
|
type = lib.types.listOf lib.types.singleLineStr;
|
|
default = [ ];
|
|
example = [
|
|
"--slice-us 5000"
|
|
"--verbose"
|
|
];
|
|
description = ''
|
|
Parameters passed to the chosen scheduler at runtime.
|
|
|
|
::: {.note}
|
|
Run `chosen-scx-scheduler --help` to see the available options. Generally,
|
|
each scheduler has its own set of options, and they are incompatible with each other.
|
|
:::
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
environment.systemPackages = [ cfg.package ];
|
|
|
|
systemd.services.scx = {
|
|
description = "SCX scheduler daemon";
|
|
|
|
# SCX service should be started only if the kernel supports sched-ext
|
|
unitConfig.ConditionPathIsDirectory = "/sys/kernel/sched_ext";
|
|
|
|
startLimitIntervalSec = 30;
|
|
startLimitBurst = 2;
|
|
|
|
serviceConfig = {
|
|
Type = "simple";
|
|
ExecStart = utils.escapeSystemdExecArgs (
|
|
[
|
|
(lib.getExe' cfg.package cfg.scheduler)
|
|
]
|
|
++ cfg.extraArgs
|
|
);
|
|
Restart = "on-failure";
|
|
};
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
};
|
|
|
|
assertions = [
|
|
{
|
|
assertion = lib.versionAtLeast config.boot.kernelPackages.kernel.version "6.12";
|
|
message = "SCX is only supported on kernel version >= 6.12.";
|
|
}
|
|
];
|
|
};
|
|
|
|
meta.maintainers = with lib.maintainers; [ johnrtitor ];
|
|
}
|