Files
nix-config/packages/cockpit-benchmark/default.nix
2026-03-23 15:17:09 -05:00

73 lines
1.7 KiB
Nix

{
fio,
jq,
lib,
namespace,
nodejs,
npmHooks,
fetchNpmDeps,
stdenv,
}:
let
inherit (lib.trivial) importJSON;
inherit (lib.${namespace}) mkAllSources selectVariant;
versionSpec = importJSON ./version.json;
selected = selectVariant versionSpec null null;
sources = mkAllSources selected;
inherit (selected.variables) version;
in
stdenv.mkDerivation (finalAttrs: {
pname = "cockpit-benchmark";
inherit version;
src = sources.src;
npmDeps = fetchNpmDeps {
src = "${finalAttrs.src}/benchmark";
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};
nativeBuildInputs = [
jq
nodejs
npmHooks.npmConfigHook
npmHooks.npmBuildHook
npmHooks.npmInstallHook
];
# fio is the runtime benchmark tool invoked by the plugin's backend script.
passthru.cockpitPath = [ fio ];
# npmConfigHook expects to run in the directory with package.json
preConfigure = ''
cd benchmark
'';
# Write version.js before vite build (mirrors what the Makefile does)
preBuild = ''
pluginVersion="$(jq -r '.version' ../manifest.json)-$(jq -r '.build_number' ../manifest.json)"
echo "export const pluginVersion = \"''${pluginVersion}\";" > src/version.js
'';
npmBuildScript = "build";
installPhase = ''
runHook preInstall
mkdir -p $out/share/cockpit/benchmark
cp -r dist/* $out/share/cockpit/benchmark/
runHook postInstall
'';
meta = {
description = "Cockpit storage benchmark utility using fio";
homepage = "https://github.com/45Drives/cockpit-benchmark";
changelog = "https://github.com/45Drives/cockpit-benchmark/releases/tag/v${version}";
license = lib.licenses.gpl3Plus;
platforms = lib.platforms.linux;
maintainers = [ ];
};
})