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="
}
}
}

View File

@@ -11,14 +11,14 @@
"owner": "cockpit-project",
"repo": "cockpit-machines",
"tag": "${version}",
"hash": "sha256-jP/ffo0kwju0xxKMHhDwOsNKO7HjOaJZ/uXYijsElNg="
"hash": "sha256-HAXOjk77y17vI/x4kFCZVNnRYrZFpqhw8PsVKmnznBM="
},
"nodeModules": {
"fetcher": "github",
"owner": "cockpit-project",
"repo": "node-cache",
"rev": "${nodeCacheRev}",
"hash": "sha256-yonEQ7hRskbFDnW/Pc3aOeV7bgu1LCYpi1Ok5/aHeC8="
"hash": "sha256-VZwFbOxtUVYXpIeCpAR3bUOjacf6DXgO6EBHPFWczQU="
},
"cockpitLib": {
"fetcher": "github",

View File

@@ -1,55 +1,55 @@
{
fetchFromGitHub,
lib,
namespace,
nodejs,
stdenv,
}:
let
inherit (lib.trivial) importJSON;
inherit (lib.${namespace}) mkAllSources selectVariant;
stdenv.mkDerivation (finalAttrs: {
versionSpec = importJSON ./version.json;
selected = selectVariant versionSpec null null;
sources = mkAllSources selected;
inherit (selected.variables) version;
in
stdenv.mkDerivation {
pname = "cockpit-podman";
version = "123";
inherit version;
src = fetchFromGitHub {
owner = "cockpit-project";
repo = "cockpit-podman";
tag = finalAttrs.version;
hash = "sha256-N5nhJU9XUsxLWq3mk3bSyorHEM4zSLHt9I+zkdgU2Vk=";
};
src = sources.src;
# Pre-vendored node_modules from cockpit-project/node-cache, pinned via the
# node_modules submodule reference in the source tree.
nodeModules = fetchFromGitHub {
owner = "cockpit-project";
repo = "node-cache";
rev = "e39ef3621b5aefa5bf1c2de7e66a5918fcef620c";
hash = "sha256-+yhHsGEN1IqIxPY7vQysp1ZczcHzXRoNIVN3DyVgwB8=";
};
inherit (sources) nodeModules;
# pkg/lib is checked out from the main cockpit repo at the pinned commit
# referenced in the Makefile (COCKPIT_REPO_COMMIT).
cockpitLib = fetchFromGitHub {
owner = "cockpit-project";
repo = "cockpit";
rev = "5fb84eaefbc5ff4433a21bc452270af8d09e1ab7";
hash = "sha256-FR6TIKQ+3GuDMOMEivDxEx6E/SVIAXh9Cg36JJ694Wc=";
};
# pkg/lib checked out from the main cockpit repo at the commit pinned in
# the Makefile (COCKPIT_REPO_COMMIT).
inherit (sources) cockpitLib;
nativeBuildInputs = [ nodejs ];
# cockpit-podman uses passthru.cockpitPath for the NixOS cockpit module to
# add runtime dependencies to the cockpit service's PATH.
# passthru.cockpitPath is used by the NixOS cockpit module to add runtime
# dependencies to the cockpit service's PATH.
passthru.cockpitPath = [ ];
configurePhase = ''
runHook preConfigure
# Wire up the vendored node_modules
cp -r ${finalAttrs.nodeModules} node_modules
# Replace the empty git submodule placeholder with the real vendored modules.
# Use dotglob so hidden entries (.bin, .package-lock.json, etc.) are included.
rm -rf node_modules
mkdir node_modules
(shopt -s dotglob; cp -r $nodeModules/* node_modules/)
chmod -R u+w node_modules
# Wire up pkg/lib from the pinned cockpit repo
# Node needs package-lock.json at the project root to resolve modules.
cp node_modules/.package-lock.json package-lock.json
# Wire up pkg/lib from the pinned cockpit repo.
mkdir -p pkg
cp -r ${finalAttrs.cockpitLib}/pkg/lib pkg/lib
cp -r $cockpitLib/pkg/lib pkg/lib
chmod -R u+w pkg
runHook postConfigure
@@ -75,9 +75,9 @@ stdenv.mkDerivation (finalAttrs: {
meta = {
description = "Cockpit UI for Podman containers";
homepage = "https://github.com/cockpit-project/cockpit-podman";
changelog = "https://github.com/cockpit-project/cockpit-podman/releases/tag/${finalAttrs.version}";
changelog = "https://github.com/cockpit-project/cockpit-podman/releases/tag/${version}";
license = lib.licenses.lgpl21Plus;
platforms = lib.platforms.linux;
maintainers = [ ];
};
})
}