fixes and docs
This commit is contained in:
72
packages/cockpit-benchmark/default.nix
Normal file
72
packages/cockpit-benchmark/default.nix
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
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 = [ ];
|
||||
};
|
||||
})
|
||||
15
packages/cockpit-benchmark/version.json
Normal file
15
packages/cockpit-benchmark/version.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"variables": {
|
||||
"version": "2.1.2"
|
||||
},
|
||||
"sources": {
|
||||
"src": {
|
||||
"fetcher": "github",
|
||||
"owner": "45Drives",
|
||||
"repo": "cockpit-benchmark",
|
||||
"tag": "v${version}",
|
||||
"hash": "sha256-YmOCdqAdYPnNcXqCccvI0nVhR/EdYXdkeenmy4DdGK0="
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user