fixes and docs

This commit is contained in:
mjallen18
2026-03-23 15:17:10 -05:00
parent 2c0b26ced0
commit 23f29b6ca1
25 changed files with 1590 additions and 795 deletions

View File

@@ -6,6 +6,7 @@
nodejs,
npmHooks,
fetchNpmDeps,
requireFile,
stdenv,
}:
let
@@ -16,6 +17,87 @@ let
selected = selectVariant versionSpec null null;
sources = mkAllSources selected;
inherit (selected.variables) version;
# These three packages are published exclusively to GitHub Packages
# (npm.pkg.github.com) which requires authentication — they cannot be
# fetched in the Nix sandbox without a token. Add them to the Nix store
# manually first:
#
# TOKEN=<your GitHub PAT with read:packages scope>
# for pkg in \
# "download/@45Drives/cockpit-css/0.1.12/42ecb717da68e4c31454b5bc6019e3a4fe7dcd6c" \
# "download/@45Drives/cockpit-helpers/0.1.19/29920cb9a0866220cfda58b9db4f34c8435f8960" \
# "download/@45Drives/cockpit-vue-components/0.1.0-beta2/a216666b3e9eb97a30cf47c0b947b4e5661798db"
# do
# curl -L -u "user:$TOKEN" \
# "https://npm.pkg.github.com/$pkg" \
# -o "$(basename $pkg).tgz"
# done
# nix store add-file *.tgz
cockpitCssTarball = requireFile {
name = "cockpit-css-0.1.12.tgz";
# sha512 integrity from yarn.lock
hash = "sha512-RgyedX/5GuriDvLruvmbqb++cIBqIF5py2E4G8/wMtQfUf6QnJqsRLYNp7uzKcLpE2+kjm9pGASdvwV2I2b/YA==";
message = ''
cockpit-benchmark requires @45drives/cockpit-css which is only available
on GitHub Packages (requires authentication). Download it manually:
curl -L -u "user:<GITHUB_PAT>" \
"https://npm.pkg.github.com/download/@45Drives/cockpit-css/0.1.12/42ecb717da68e4c31454b5bc6019e3a4fe7dcd6c" \
-o cockpit-css-0.1.12.tgz
nix store add-file cockpit-css-0.1.12.tgz
'';
};
cockpitHelpersTarball = requireFile {
name = "cockpit-helpers-0.1.19.tgz";
hash = "sha512-dyS3V+XG/9rLGGhFJEA2b+ohrZiGsHteOEktJk9mM9c6WsXJywrlnrHm0YrKksoTUPwXtBY44QrXJNd3zKtvKQ==";
message = ''
cockpit-benchmark requires @45drives/cockpit-helpers which is only available
on GitHub Packages (requires authentication). Download it manually:
curl -L -u "user:<GITHUB_PAT>" \
"https://npm.pkg.github.com/download/@45Drives/cockpit-helpers/0.1.19/29920cb9a0866220cfda58b9db4f34c8435f8960" \
-o cockpit-helpers-0.1.19.tgz
nix store add-file cockpit-helpers-0.1.19.tgz
'';
};
cockpitVueComponentsTarball = requireFile {
name = "cockpit-vue-components-0.1.0-beta2.tgz";
hash = "sha512-QvKCuUlCA9LLrwdGKf1iveiKUvJaExmNZxOUyhxg63BvQwn9rs26uN/MFS2mweCi++Mv6kyN+dJG62L7qCSOXQ==";
message = ''
cockpit-benchmark requires @45drives/cockpit-vue-components which is only
available on GitHub Packages (requires authentication). Download it manually:
curl -L -u "user:<GITHUB_PAT>" \
"https://npm.pkg.github.com/download/@45Drives/cockpit-vue-components/0.1.0-beta2/a216666b3e9eb97a30cf47c0b947b4e5661798db" \
-o cockpit-vue-components-0.1.0-beta2.tgz
nix store add-file cockpit-vue-components-0.1.0-beta2.tgz
'';
};
# Rewrite the package-lock.json to point the three GitHub Packages deps at
# their local store paths so fetchNpmDeps / npm ci can find them offline.
patchedPackageLock =
let
lockFile = "${sources.src}/benchmark/package-lock.json";
in
stdenv.mkDerivation {
name = "cockpit-benchmark-package-lock-patched.json";
nativeBuildInputs = [ jq ];
buildCommand = ''
jq \
--arg cssPath "${cockpitCssTarball}" \
--arg helpersPath "${cockpitHelpersTarball}" \
--arg vuePath "${cockpitVueComponentsTarball}" \
'
.packages["node_modules/@45drives/cockpit-css"].resolved = ("file://" + $cssPath) |
.packages["node_modules/@45drives/cockpit-helpers"].resolved = ("file://" + $helpersPath) |
.packages["node_modules/@45drives/cockpit-vue-components"].resolved = ("file://" + $vuePath)
' ${lockFile} > $out
'';
};
in
stdenv.mkDerivation (finalAttrs: {
pname = "cockpit-benchmark";
@@ -25,6 +107,7 @@ stdenv.mkDerivation (finalAttrs: {
npmDeps = fetchNpmDeps {
src = "${finalAttrs.src}/benchmark";
packageLock = patchedPackageLock;
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};
@@ -33,19 +116,21 @@ stdenv.mkDerivation (finalAttrs: {
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
# npmConfigHook expects package.json and node_modules in the working dir
cp -r benchmark/. .
# replace package-lock.json with the patched version that uses store paths
cp ${patchedPackageLock} package-lock.json
chmod u+w package-lock.json
'';
# Write version.js before vite build (mirrors what the Makefile does)
preBuild = ''
# Write version.js before vite build (mirrors what the Makefile does)
pluginVersion="$(jq -r '.version' ../manifest.json)-$(jq -r '.build_number' ../manifest.json)"
echo "export const pluginVersion = \"''${pluginVersion}\";" > src/version.js
'';

View File

@@ -9,7 +9,7 @@
"owner": "45Drives",
"repo": "cockpit-benchmark",
"tag": "v${version}",
"hash": "sha256-YmOCdqAdYPnNcXqCccvI0nVhR/EdYXdkeenmy4DdGK0="
"hash": "sha256-AYGaTwNNAH4rl+AdYAoktkjVBcrBqYcfaihYAEq2Dic="
}
}
}