nixos/scx-loader: init

This commit is contained in:
ccicnce113424
2026-06-04 15:03:06 +08:00
parent 699d54fd13
commit 472e7bfd45
3 changed files with 98 additions and 0 deletions
@@ -12,6 +12,8 @@
- [tranquil](https://tangled.org/tranquil.farm/tranquil-pds) is an ATProto PDS (personal data server) implementation in Rust. A featureful, spec conscious and community driven alternative to the Bluesky reference implementation PDS. Available as [services.tranquil-pds](#opt-services.tranquil-pds.enable).
- [scx_loader](https://github.com/sched-ext/scx-loader), a system daemon and DBus-based loader for sched_ext schedulers. `scxctl` is the command-line client for interacting with the loader, allowing users to switch schedulers, modes, and arguments dynamically. Available as [services.scx-loader](#opt-services.scx-loader.enable)
- [FlapAlerted](https://github.com/Kioubit/FlapAlerted), detects BGP flapping events and provides statistics based on BGP update messages. Available as [services.flap-alerted](#opt-services.flap-alerted.enable).
## Backward Incompatibilities {#sec-release-26.11-incompatibilities}
+1
View File
@@ -1483,6 +1483,7 @@
./services/scheduling/cron.nix
./services/scheduling/fcron.nix
./services/scheduling/prefect.nix
./services/scheduling/scx-loader.nix
./services/scheduling/scx.nix
./services/search/elasticsearch-curator.nix
./services/search/elasticsearch.nix
@@ -0,0 +1,95 @@
{
lib,
pkgs,
config,
...
}:
let
cfg = config.services.scx-loader;
settingsFormat = pkgs.formats.toml { };
configFile = settingsFormat.generate "scx_loader.toml" (
lib.filterAttrsRecursive (_: v: v != null) cfg.config
);
schedulers = builtins.concatMap (
x: x.passthru.schedulers or (throw "Scheduler not found in package ${x.name}")
) cfg.schedsPackages;
in
{
options.services.scx-loader = {
enable = lib.mkEnableOption "SCX Loader service, a daemon to run schedulers from userspace using dbus. This requires kernel version 6.12 and later.";
package = lib.mkPackageOption pkgs "scx-loader" { };
schedsPackages = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [ pkgs.scx.rustscheds ];
defaultText = lib.literalExpression "[ pkgs.scx.rustscheds ]";
example = lib.literalExpression "[ pkgs.scx.full ]";
description = ''
`scx` package to use. Defaults to `scx.rustscheds`, which includes all currently by `scx_loader` supported schedulers.
'';
};
config = lib.mkOption {
type = lib.types.submodule {
freeformType = settingsFormat.type;
options = {
default_sched = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "scx_bpfland";
description = ''
Default scheduler that will be started automatically when `scx_loader` starts.
If not set or set to an empty string, `scx_loader` will not start any scheduler by default.
'';
};
};
};
default = { };
description = ''
Configuration for `scx_loader`.
See <https://github.com/sched-ext/scx-loader/blob/main/crates/scx_loader/configuration.md> for the full list of options.
'';
};
};
config = lib.mkIf cfg.enable {
assertions = [
{
assertion = lib.versionAtLeast config.boot.kernelPackages.kernel.version "6.12";
message = "SCX is only supported on kernel version 6.12 and above.";
}
{
assertion = !config.services.scx.enable;
message = "services.scx and services.scx_loader cannot be enabled simultaneously. Please enable only one of them.";
}
{
assertion =
cfg.config.default_sched == null || lib.elem cfg.config.default_sched ([ "" ] ++ schedulers);
message = ''
Invalid default scheduler: ${cfg.config.default_sched}. It must be one of: ${lib.concatStringsSep ", " schedulers}.
'';
}
];
environment.systemPackages = [ cfg.package ] ++ cfg.schedsPackages;
systemd.packages = [ cfg.package ];
services.dbus.packages = [ cfg.package ];
security.polkit.enable = true;
systemd.services.scx_loader = {
path = cfg.schedsPackages;
wantedBy = [ "multi-user.target" ];
serviceConfig = {
TemporaryFileSystem = [ "/etc" ];
BindReadOnlyPaths = [ "${configFile.outPath}:/etc/scx_loader.toml" ];
};
};
};
meta.maintainers = with lib.maintainers; [ ccicnce113424 ];
}