push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
{
lib,
callPackage,
fetchFromGitHub,
}:
let
scx-common = rec {
versionInfo = lib.importJSON ./version.json;
inherit (versionInfo.scx) version;
src = fetchFromGitHub {
owner = "sched-ext";
repo = "scx";
tag = "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
Gliczy
];
};
};
schedulers = lib.mergeAttrsList [
{ cscheds = import ./scx_cscheds.nix; }
{ rustscheds = import ./scx_rustscheds.nix; }
{ full = import ./scx_full.nix; }
];
in
(lib.mapAttrs (name: scheduler: callPackage scheduler { inherit scx-common; }) schedulers)
// {
inherit scx-common;
}

View File

@@ -0,0 +1,123 @@
{
lib,
llvmPackages,
fetchFromGitHub,
writeShellScript,
bash,
meson,
ninja,
jq,
pkg-config,
bpftools,
elfutils,
zlib,
zstd,
scx-common,
protobuf,
libseccomp,
}:
llvmPackages.stdenv.mkDerivation (finalAttrs: {
pname = "scx_cscheds";
inherit (scx-common) version src;
# scx needs specific commits of bpftool and libbpf
# can be found in meson.build of scx src
# grep 'bpftool_commit =' ./meson.build
bpftools_src = fetchFromGitHub {
owner = "libbpf";
repo = "bpftool";
inherit (scx-common.versionInfo.bpftool) rev hash;
fetchSubmodules = true;
};
# grep 'libbpf_commit = ' ./meson.build
libbpf_src = fetchFromGitHub {
owner = "libbpf";
repo = "libbpf";
inherit (scx-common.versionInfo.libbpf) rev hash;
fetchSubmodules = true;
};
# this imitates the fetch_bpftool and fetch_libbpf script in src/meson-scripts
fetchBpftool = writeShellScript "fetch_bpftool" ''
[ "$2" == '${finalAttrs.bpftools_src.rev}' ] || exit 1
cd "$1"
cp --no-preserve=mode,owner -r "${finalAttrs.bpftools_src}/" ./bpftool
'';
fetchLibbpf = writeShellScript "fetch_libbpf" ''
[ "$2" == '${finalAttrs.libbpf_src.rev}' ] || exit 1
cd "$1"
cp --no-preserve=mode,owner -r "${finalAttrs.libbpf_src}/" ./libbpf
mkdir -p ./libbpf/src/usr/include
'';
postPatch = ''
rm meson-scripts/fetch_bpftool meson-scripts/fetch_libbpf
patchShebangs ./meson-scripts
cp ${finalAttrs.fetchBpftool} meson-scripts/fetch_bpftool
cp ${finalAttrs.fetchLibbpf} meson-scripts/fetch_libbpf
substituteInPlace ./meson-scripts/build_bpftool \
--replace-fail '/bin/bash' '${lib.getExe bash}'
'';
nativeBuildInputs = [
meson
ninja
jq
pkg-config
zstd
protobuf
llvmPackages.libllvm
]
++ bpftools.buildInputs
++ bpftools.nativeBuildInputs;
buildInputs = [
elfutils
zlib
libseccomp
];
mesonFlags = [
(lib.mapAttrsToList lib.mesonEnable {
# systemd unit is implemented in the nixos module
# upstream systemd files are a hassle to patch
"systemd" = false;
# not for nix
"openrc" = false;
})
(lib.mapAttrsToList lib.mesonBool {
# needed libs are already fetched as FOD
"offline" = true;
# rust based schedulers are built separately
"enable_rust" = false;
})
# Clang to use when compiling .bpf.c
(lib.mesonOption "bpf_clang" (lib.getExe llvmPackages.clang))
];
hardeningDisable = [
"stackprotector"
"zerocallusedregs"
];
outputs = [
"bin"
"out"
];
doCheck = true;
meta = scx-common.meta // {
description = "Sched-ext C userspace schedulers";
longDescription = ''
This includes C based schedulers such as scx_central, scx_flatcg,
scx_nest, scx_pair, scx_qmap, scx_simple, scx_userland.
::: {.note}
Sched-ext schedulers are only available on kernels version 6.12 or later.
It is recommended to use the latest kernel for the best compatibility.
:::
'';
};
})

View File

@@ -0,0 +1,31 @@
{
lib,
stdenv,
scx-common,
scx,
nixosTests,
}:
scx.cscheds.overrideAttrs (oldAttrs: {
pname = "scx_full";
postInstall = (oldAttrs.postInstall or "") + ''
cp ${scx.rustscheds}/bin/* ${placeholder "bin"}/bin/
'';
passthru.tests.basic = nixosTests.scx;
passthru.updateScript.command = ./update.sh;
meta = oldAttrs.meta // {
description = "Sched-ext C and Rust userspace schedulers";
longDescription = ''
This includes C based schedulers such as scx_central, scx_flatcg,
scx_pair, scx_qmap, scx_simple, scx_userland and Rust based schedulers
like scx_rustland, scx_bpfland, scx_lavd, scx_layered, scx_rlfifo.
::: {.note}
Sched-ext schedulers are only available on kernels version 6.12 or later.
It is recommended to use the latest kernel for the best compatibility.
:::
'';
};
})

View File

@@ -0,0 +1,68 @@
{
lib,
rustPlatform,
llvmPackages,
pkg-config,
elfutils,
zlib,
zstd,
scx-common,
protobuf,
libseccomp,
}:
rustPlatform.buildRustPackage {
pname = "scx_rustscheds";
inherit (scx-common) version src;
inherit (scx-common.versionInfo.scx) cargoHash;
nativeBuildInputs = [
pkg-config
rustPlatform.bindgenHook
protobuf
];
buildInputs = [
elfutils
zlib
zstd
libseccomp
];
env = {
BPF_CLANG = lib.getExe llvmPackages.clang;
RUSTFLAGS = lib.concatStringsSep " " [
"-C relocation-model=pic"
"-C link-args=-lelf"
"-C link-args=-lz"
"-C link-args=-lzstd"
];
};
hardeningDisable = [
"stackprotector"
"zerocallusedregs"
];
doCheck = true;
checkFlags = [
"--skip=compat::tests::test_ksym_exists"
"--skip=compat::tests::test_read_enum"
"--skip=compat::tests::test_struct_has_field"
"--skip=cpumask"
"--skip=topology"
"--skip=proc_data::tests::test_thread_operations"
];
meta = scx-common.meta // {
description = "Sched-ext Rust userspace schedulers";
longDescription = ''
This includes Rust based schedulers such as
scx_rustland, scx_bpfland, scx_lavd, scx_layered, scx_rlfifo.
::: {.note}
Sched-ext schedulers are only available on kernels version 6.12 or later.
It is recommended to use the latest kernel for the best compatibility.
:::
'';
};
}

View File

@@ -0,0 +1,57 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p coreutils moreutils curl jq nix-prefetch-git cargo gnugrep gawk nix
# shellcheck shell=bash
# You must run it from the root directory of a nixpkgs repo checkout
set -euo pipefail
versionJson="$(realpath "./pkgs/os-specific/linux/scx/version.json")"
nixFolder="$(dirname "$versionJson")"
localVer=$(jq -r .scx.version <$versionJson)
latestVer=$(curl -s https://api.github.com/repos/sched-ext/scx/releases/latest | jq -r .tag_name | sed 's/v//g')
if [ "$localVer" == "$latestVer" ]; then
exit 0
fi
latestHash=$(nix-prefetch-git https://github.com/sched-ext/scx.git --rev refs/tags/v$latestVer --quiet | jq -r .hash)
tmp=$(mktemp -d)
trap 'rm -rf -- "${tmp}"' EXIT
git clone --depth 1 --branch "v$latestVer" https://github.com/sched-ext/scx.git "$tmp/scx"
pushd "$tmp/scx"
bpftoolRev=$(grep 'bpftool_commit =' ./meson.build | awk -F"'" '{print $2}')
bpftoolHash=$(nix-prefetch-git https://github.com/libbpf/bpftool.git --rev $bpftoolRev --fetch-submodules --quiet | jq -r .hash)
libbpfRev=$(grep 'libbpf_commit =' ./meson.build | awk -F"'" '{print $2}')
libbpfHash=$(nix-prefetch-git https://github.com/libbpf/libbpf.git --rev $libbpfRev --fetch-submodules --quiet | jq -r .hash)
jq \
--arg latestVer "$latestVer" --arg latestHash "$latestHash" \
--arg bpftoolRev "$bpftoolRev" --arg bpftoolHash "$bpftoolHash" \
--arg libbpfRev "$libbpfRev" --arg libbpfHash "$libbpfHash" \
".scx.version = \$latestVer | .scx.hash = \$latestHash |\
.bpftool.rev = \$bpftoolRev | .bpftool.hash = \$bpftoolHash |\
.libbpf.rev = \$libbpfRev | .libbpf.hash = \$libbpfHash" \
"$versionJson" | sponge $versionJson
echo "scx: $localVer -> $latestVer"
echo "Updating cargoHash. This may take a while..."
popd
cargoHash=$((nix-build --attr scx.rustscheds 2>&1 || true) | awk '/got/{print $2}')
if [ -z "$cargoHash" ]; then
echo "Failed to get cargoHash, please update it manually"
exit 0
fi
jq \
--arg cargoHash "$cargoHash" \
".scx.cargoHash = \$cargoHash" \
"$versionJson" | sponge $versionJson

View File

@@ -0,0 +1,15 @@
{
"scx": {
"version": "1.0.16",
"hash": "sha256-fL8SlwIJOEme3bUTk1huv61jg/2QUWtUFaplM3DmCWI=",
"cargoHash": "sha256-CrQclEsb/Bkoe3SI069vKWiIUepk8f1Tts1MKpgphsM="
},
"bpftool": {
"rev": "183e7010387d1fc9f08051426e9a9fbd5f8d409e",
"hash": "sha256-ZZly6csVWOmtLmld1fhSDUqyRgZx2gSMGXTaSASGv7c="
},
"libbpf": {
"rev": "b4fa3e39a77fd65574fb5f899486795fc3d89bd9",
"hash": "sha256-wlymVgcLlGCUOC92CkYU6QZZnqx8nidSfhr1pTiS8aM="
}
}