scx.cscheds: let it fetch it's own libbpf
This commit is contained in:
parent
1f8150661e
commit
d285c731ed
@ -11,13 +11,13 @@
|
||||
bpftools,
|
||||
elfutils,
|
||||
zlib,
|
||||
libbpf,
|
||||
zstd,
|
||||
}:
|
||||
|
||||
let
|
||||
versionInfo = lib.importJSON ./version.json;
|
||||
|
||||
# scx needs a specific commit of bpftool
|
||||
# scx needs a specific commit of bpftool and libbpf
|
||||
# can be found in meson.build of scx src
|
||||
# grep 'bpftool_commit =' ./meson.build
|
||||
bpftools_src = fetchFromGitHub {
|
||||
@ -26,6 +26,13 @@ let
|
||||
inherit (versionInfo.bpftool) rev hash;
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
# grep 'libbpf_commit = ' ./meson.build
|
||||
libbpf_src = fetchFromGitHub {
|
||||
owner = "libbpf";
|
||||
repo = "libbpf";
|
||||
inherit (versionInfo.libbpf) rev hash;
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
# scx needs a specific commit of bpftool
|
||||
# this imitates the fetch_bpftool script in src/meson-scripts
|
||||
@ -34,6 +41,12 @@ let
|
||||
cd "$1"
|
||||
cp --no-preserve=mode,owner -r "${bpftools_src}/" ./bpftool
|
||||
'';
|
||||
fetchLibbpf = writeShellScript "fetch_libbpf" ''
|
||||
[ "$2" == '${libbpf_src.rev}' ] || exit 1
|
||||
cd "$1"
|
||||
cp --no-preserve=mode,owner -r "${libbpf_src}/" ./libbpf
|
||||
mkdir -p ./libbpf/src/usr/include
|
||||
'';
|
||||
|
||||
# Fixes a bug with the meson build script where it specifies
|
||||
# /bin/bash twice in the script
|
||||
@ -42,24 +55,15 @@ let
|
||||
exec ${lib.getExe bash} "$@"
|
||||
'';
|
||||
|
||||
# Won't build with stable libbpf, so use the latest commit
|
||||
libbpf-git = libbpf.overrideAttrs (oldAttrs: {
|
||||
src = fetchFromGitHub {
|
||||
owner = "libbpf";
|
||||
repo = "libbpf";
|
||||
inherit (versionInfo.libbpf) rev hash;
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
});
|
||||
|
||||
in
|
||||
mkScxScheduler "c" {
|
||||
schedulerName = "scx_cscheds";
|
||||
|
||||
postPatch = ''
|
||||
rm meson-scripts/fetch_bpftool
|
||||
rm meson-scripts/fetch_bpftool meson-scripts/fetch_libbpf
|
||||
patchShebangs ./meson-scripts
|
||||
cp ${fetchBpftool} meson-scripts/fetch_bpftool
|
||||
cp ${fetchLibbpf} meson-scripts/fetch_libbpf
|
||||
substituteInPlace meson.build \
|
||||
--replace-fail '[build_bpftool' "['${misbehaviorBash}', build_bpftool"
|
||||
'';
|
||||
@ -73,7 +77,7 @@ mkScxScheduler "c" {
|
||||
buildInputs = [
|
||||
elfutils
|
||||
zlib
|
||||
libbpf-git
|
||||
zstd
|
||||
];
|
||||
|
||||
mesonFlags = [
|
||||
@ -82,8 +86,6 @@ mkScxScheduler "c" {
|
||||
# upstream systemd files are a hassle to patch
|
||||
"systemd" = false;
|
||||
"openrc" = false;
|
||||
# libbpf is already fetched as FOD
|
||||
"libbpf_a" = false;
|
||||
# not for nix
|
||||
"libalpm" = false;
|
||||
})
|
||||
|
@ -26,7 +26,7 @@ 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=$(curl -s "https://api.github.com/repos/libbpf/libbpf/commits/master" | jq -r '.sha')
|
||||
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 \
|
||||
|
@ -8,7 +8,7 @@
|
||||
"hash": "sha256-pItTVewlXgB97AC/WH9rW9J/eYSe2ZdBkJaAgGnDeUU="
|
||||
},
|
||||
"libbpf": {
|
||||
"rev": "09b9e83102eb8ab9e540d36b4559c55f3bcdb95d",
|
||||
"hash": "sha256-0PadA9OppNGmgSTLi8sXrh3syxPVkqrnTkBr8cyp+Ug="
|
||||
"rev": "686f600bca59e107af4040d0838ca2b02c14ff50",
|
||||
"hash": "sha256-uIu57gFkPhBCq3RqKb6J4r5OB4X5/V9q8HqIafUc+Do="
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user