Unverified Commit 286aa47c authored by John Titor's avatar John Titor
Browse files

scx: remove need for custom update script

nix-shell maintainers/scripts/update.nix --argstr package scx.rustscheds

Should be ran from now on
parent 68f2d23b
Loading
Loading
Loading
Loading
+4 −35
Original line number Diff line number Diff line
{
  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;
lib.mapAttrs (name: scheduler: callPackage scheduler { }) {
  cscheds = import ./scx_cscheds.nix;
  rustscheds = import ./scx_rustscheds.nix;
  full = import ./scx_full.nix;
}
+7 −3
Original line number Diff line number Diff line
@@ -6,13 +6,13 @@
  elfutils,
  zlib,
  zstd,
  scx-common,
  scx,
  libseccomp,
}:

llvmPackages.stdenv.mkDerivation (finalAttrs: {
  pname = "scx_cscheds";
  inherit (scx-common) version src;
  inherit (scx.rustscheds) version src;

  postPatch = ''
    substituteInPlace ./scheds/c/Makefile \
@@ -42,7 +42,11 @@ llvmPackages.stdenv.mkDerivation (finalAttrs: {

  doCheck = true;

  meta = scx-common.meta // {
  passthru = {
    inherit (scx.rustscheds.passthru) tests;
  };

  meta = scx.rustscheds.meta // {
    description = "Sched-ext C userspace schedulers";
    longDescription = ''
      This includes C based schedulers such as scx_central, scx_flatcg,
+0 −7
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  scx-common,
  scx,
  nixosTests,
}:
scx.cscheds.overrideAttrs (oldAttrs: {
  pname = "scx_full";
@@ -11,10 +8,6 @@ scx.cscheds.overrideAttrs (oldAttrs: {
    cp ${lib.getBin scx.rustscheds}/bin/* ${placeholder "out"}/bin/
  '';

  passthru.tests.basic = nixosTests.scx;

  passthru.updateScript.command = ./update.sh;

  meta = oldAttrs.meta // {
    description = "Sched-ext C and Rust userspace schedulers";
    longDescription = ''
+28 −6
Original line number Diff line number Diff line
@@ -6,15 +6,24 @@
  elfutils,
  zlib,
  zstd,
  scx-common,
  fetchFromGitHub,
  protobuf,
  libseccomp,
  nix-update-script,
  nixosTests,
}:
rustPlatform.buildRustPackage {
rustPlatform.buildRustPackage (finalAttrs: {
  pname = "scx_rustscheds";
  inherit (scx-common) version src;
  version = "1.0.17";

  inherit (scx-common.versionInfo.scx) cargoHash;
  src = fetchFromGitHub {
    owner = "sched-ext";
    repo = "scx";
    tag = "v${finalAttrs.version}";
    hash = "sha256-UhFHT8cSrdjhSqjj4qFzn5UvfPOLPwrBh1ytL2gFhzU=";
  };

  cargoHash = "sha256-yQM2zx1IzGjegwLK4epsluWl8m5RSP3jB00Lpd8+TLE=";

  nativeBuildInputs = [
    pkg-config
@@ -52,7 +61,10 @@ rustPlatform.buildRustPackage {
    "--skip=proc_data::tests::test_thread_operations"
  ];

  meta = scx-common.meta // {
  passthru.tests.basic = nixosTests.scx;
  passthru.updateScript = nix-update-script { };

  meta = {
    description = "Sched-ext Rust userspace schedulers";
    longDescription = ''
      This includes Rust based schedulers such as
@@ -63,5 +75,15 @@ rustPlatform.buildRustPackage {
      It is recommended to use the latest kernel for the best compatibility.
      :::
    '';

    homepage = "https://github.com/sched-ext/scx";
    changelog = "https://github.com/sched-ext/scx/releases/tag/v${finalAttrs.version}";
    license = lib.licenses.gpl2Only;
    platforms = lib.platforms.linux;
    badPlatforms = [ "aarch64-linux" ];
    maintainers = with lib.maintainers; [
      johnrtitor
      Gliczy
    ];
  };
}
})
+0 −39
Original line number Diff line number Diff line
#! /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)

jq \
  --arg latestVer "$latestVer" --arg latestHash "$latestHash" \
  ".scx.version = \$latestVer | .scx.hash = \$latestHash" \
  "$versionJson" | sponge $versionJson

echo "scx: $localVer -> $latestVer"

echo "Updating cargoHash. This may take a while..."
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
Loading