Skip to content

Commit

Permalink
scx: 1.0.5 -> 1.0.6; build all rust subpackages together (#358154)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRTitor authored Nov 23, 2024
2 parents 0d509f7 + 9480c8b commit 773ebf1
Show file tree
Hide file tree
Showing 19 changed files with 195 additions and 10,004 deletions.
4 changes: 2 additions & 2 deletions nixos/modules/services/scheduling/scx.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ in
type = lib.types.package;
default = pkgs.scx.full;
defaultText = lib.literalExpression "pkgs.scx.full";
example = lib.literalExpression "pkgs.scx.rustland";
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.rustland`, if only one specific scheduler is needed.
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.
Expand Down
89 changes: 24 additions & 65 deletions pkgs/os-specific/linux/scx/default.nix
Original file line number Diff line number Diff line change
@@ -1,79 +1,38 @@
{
lib,
callPackage,
pkg-config,
rustPlatform,
llvmPackages,
elfutils,
zlib,
fetchFromGitHub,
}:
let
versionInfo = lib.importJSON ./version.json;

# Useful function for packaging schedulers, should be used unless the build system is too complex
# passes some default values like src, version (all of which can be overridden)
mkScxScheduler =
packageType:
args@{ schedulerName, ... }:
(if packageType == "rust" then rustPlatform.buildRustPackage else llvmPackages.stdenv.mkDerivation)
(
args
// {
pname = "${schedulerName}";
version = args.version or versionInfo.scx.version;

src = args.src or fetchFromGitHub {
owner = "sched-ext";
repo = "scx";
rev = "refs/tags/v${versionInfo.scx.version}";
inherit (versionInfo.scx) hash;
};

nativeBuildInputs = [
pkg-config
llvmPackages.clang
] ++ (args.nativeBuildInputs or [ ]);
buildInputs = [
elfutils
zlib
] ++ (args.buildInputs or [ ]);

env.LIBCLANG_PATH = args.env.LIBCLANG_PATH or "${lib.getLib llvmPackages.libclang}/lib";

# Needs to be disabled in BPF builds
hardeningDisable = [
"zerocallusedregs"
] ++ (args.hardeningDisable or [ ]);

meta = (args.meta or { }) // {
description = args.meta.description or "";
longDescription =
(args.meta.longDescription or "")
+ ''
\n\nSched-ext schedulers are only available on supported kernels
(6.12 and above or any kernel with the scx patchset applied).'';

homepage = args.meta.homepage or "https://github.com/sched-ext/scx";
license = args.meta.license or lib.licenses.gpl2Only;
platforms = args.meta.platforms or lib.platforms.linux;
maintainers = (args.meta.maintainers or [ ]) ++ (with lib.maintainers; [ johnrtitor ]);
};
}
);
scx-common = rec {
versionInfo = lib.importJSON ./version.json;

inherit (versionInfo.scx) version;

src = fetchFromGitHub {
owner = "sched-ext";
repo = "scx";
rev = "refs/tags/v${versionInfo.scx.version}";
inherit (versionInfo.scx) hash;
};

meta = {
homepage = "https://github.com/sched-ext/scx";
changelog = "https://github.com/sched-ext/scx/releases/tag/v${versionInfo.scx.version}";
license = lib.licenses.gpl2Only;
platforms = lib.platforms.linux;
badPlatforms = [ "aarch64-linux" ];
maintainers = with lib.maintainers; [ johnrtitor ];
};
};

schedulers = lib.mergeAttrsList [
{ bpfland = import ./scx_bpfland; }
{ lavd = import ./scx_lavd; }
{ layered = import ./scx_layered; }
{ rlfifo = import ./scx_rlfifo; }
{ rustland = import ./scx_rustland; }
{ rusty = import ./scx_rusty; }
{ cscheds = import ./scx_cscheds.nix; }
{ rustscheds = import ./scx_rustscheds.nix; }
{ full = import ./scx_full.nix; }
];
in
(lib.mapAttrs (name: scheduler: callPackage scheduler { inherit mkScxScheduler; }) schedulers)
(lib.mapAttrs (name: scheduler: callPackage scheduler { inherit scx-common; }) schedulers)
// {
inherit mkScxScheduler;
inherit scx-common;
}
Loading

0 comments on commit 773ebf1

Please sign in to comment.