Gaetan Lepage 2025-06-28 23:14:22 +02:00
parent d54c8284ae
commit be0d7b9e1a

View File

@ -9,10 +9,12 @@
# nativeBuildInputs # nativeBuildInputs
blueprint-compiler, blueprint-compiler,
cargo, cargo,
makeWrapper,
libxml2, libxml2,
meson, meson,
ninja, ninja,
pkg-config, pkg-config,
protobuf,
python3, python3,
rustc, rustc,
wrapGAppsHook4, wrapGAppsHook4,
@ -28,22 +30,28 @@
glib, glib,
graphene, graphene,
gtk4, gtk4,
libGL,
libadwaita, libadwaita,
libdrm, libdrm,
libgbm, libgbm,
pango, pango,
sqlite, sqlite,
udev, udev,
vulkan-loader,
wayland, wayland,
# magpie wrapper
libGL,
vulkan-loader,
versionCheckHook, versionCheckHook,
}: }:
# UPDATE PROCESS: # UPDATE PROCESS:
# 1) Get the nvtop commit hash (`source-url` in `nvtop.json`): # 1) Get the nvtop commit hash (`source-url` in `nvtop.json`):
# https://gitlab.com/mission-center-devs/mission-center/-/blob/v<VERSION>/src/sys_info_v2/gatherer/3rdparty/nvtop/nvtop.json?ref_type=tags # - Go to https://gitlab.com/mission-center-devs/mission-center/-/blob/v<VERSION>/subprojects
# - Click on magpie
# - Open platform-linux/3rdparty/nvtop/nvtop.json
# - The hash is in `source-url`
#
# 2) Update the version of the main derivation # 2) Update the version of the main derivation
# 3) Refresh all hashes: # 3) Refresh all hashes:
# - main `src` # - main `src`
@ -54,32 +62,67 @@ let
nvtop = fetchFromGitHub { nvtop = fetchFromGitHub {
owner = "Syllo"; owner = "Syllo";
repo = "nvtop"; repo = "nvtop";
rev = "20ea55dbd1eeb4342ff0112fae3ee2a0bfe352ea"; rev = "73291884d926445e499d6b9b71cb7a9bdbc7c393";
hash = "sha256-8lNvxmNAqkmBPFeiYIGtpW0hYXA9N0l4HURew5loj+g="; hash = "sha256-8iChT55L2NSnHg8tLIry0rgi/4966MffShE0ib+2ywc=";
}; };
in in
stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: {
pname = "mission-center"; pname = "mission-center";
version = "0.6.2"; version = "1.0.2";
src = fetchFromGitLab { src = fetchFromGitLab {
owner = "mission-center-devs"; owner = "mission-center-devs";
repo = "mission-center"; repo = "mission-center";
rev = "v${version}"; tag = "v${finalAttrs.version}";
hash = "sha256-PvHIvWyhGovlLaeHk2WMp3yRz4VxvvINzX1oqkFgVuQ="; fetchSubmodules = true;
hash = "sha256-TvrYwuJR03mvPc8oXBx6GClOLc+r5kblaOj0uaLwbwE=";
}; };
postPatch =
# Prevent platform-linux/build.rs from downloading nvtop
''
substituteInPlace src/magpie_client/client.rs \
--replace-fail \
'"missioncenter-magpie"' \
'"${placeholder "out"}/bin/missioncenter-magpie"'
SRC_DIR=$NIX_BUILD_TOP/source
SRC_MAGPIE_DIR=$SRC_DIR/subprojects/magpie
SRC_NVTOP_DIR=$SRC_MAGPIE_DIR/platform-linux/3rdparty/nvtop
# Patch references in nvtop.json to match the name we inject manually
substituteInPlace "$SRC_NVTOP_DIR/nvtop.json" \
--replace-fail "nvtop-${nvtop.rev}" "nvtop-src"
DEST_NVTOP_DIR=$SRC_DIR/build/subprojects/magpie/src/debug/build/native/nvtop-src
mkdir -p "$DEST_NVTOP_DIR"
cp -r --no-preserve=mode,ownership "${nvtop}"/* "$DEST_NVTOP_DIR"
pushd "$DEST_NVTOP_DIR"
mkdir -p include/libdrm
for patchfile in "$SRC_NVTOP_DIR"/patches/nvtop*.patch; do
patch -p1 < "$patchfile"
done
popd
''
# Patch the shebang of this python script called at build time
+ ''
patchShebangs $SRC_MAGPIE_DIR/platform-linux/hwdb/generate_hwdb.py
'';
cargoDeps = symlinkJoin { cargoDeps = symlinkJoin {
name = "cargo-vendor-dir"; name = "cargo-vendor-dir";
paths = [ paths = [
(rustPlatform.fetchCargoVendor { (rustPlatform.fetchCargoVendor {
inherit pname version src; inherit (finalAttrs) pname version src;
hash = "sha256-Yd6PlsSo8/yHMF4YdYz1Io4uGniAMyIj2RKy3yK4byU="; hash = "sha256-1Bcxp0EuHbJrLQIb2STLNIL2BM2eOgL8ftx4g1o/JY4=";
}) })
(rustPlatform.fetchCargoVendor { (rustPlatform.fetchCargoVendor {
inherit pname version src; pname = "${finalAttrs.pname}-magpie";
sourceRoot = "${src.name}/src/sys_info_v2/gatherer"; inherit (finalAttrs) version src;
hash = "sha256-oUAPJWNElj08jfmsdXz/o2bgzeBQsbm6nWHC8jGN2n0="; sourceRoot = "${finalAttrs.src.name}/subprojects/magpie";
hash = "sha256-ouY9zSQ7csAqPzQrbWGtCTB9ECVBKOUX78K5SiqTTxg=";
}) })
]; ];
}; };
@ -88,14 +131,17 @@ stdenv.mkDerivation rec {
blueprint-compiler blueprint-compiler
cargo cargo
libxml2 libxml2
makeWrapper
meson meson
ninja ninja
pkg-config pkg-config
python3 python3
protobuf # for protoc
rustPlatform.cargoSetupHook rustPlatform.cargoSetupHook
rustc rustc
wrapGAppsHook4 wrapGAppsHook4
]; ];
dontUseCmakeConfigure = true;
buildInputs = [ buildInputs = [
appstream-glib appstream-glib
@ -109,64 +155,36 @@ stdenv.mkDerivation rec {
glib glib
graphene graphene
gtk4 gtk4
libGL
libadwaita libadwaita
libdrm libdrm
libgbm libgbm
pango pango
sqlite sqlite
udev udev
vulkan-loader
wayland wayland
]; ];
postPatch = ''
substituteInPlace src/sys_info_v2/gatherer.rs \
--replace-fail '"missioncenter-gatherer"' '"${placeholder "out"}/bin/missioncenter-gatherer"'
SRC_GATHERER=$NIX_BUILD_TOP/source/src/sys_info_v2/gatherer
SRC_GATHERER_NVTOP=$SRC_GATHERER/3rdparty/nvtop
substituteInPlace $SRC_GATHERER_NVTOP/nvtop.json \
--replace-fail "nvtop-${nvtop.rev}" "nvtop-src"
GATHERER_BUILD_DEST=$NIX_BUILD_TOP/source/build/src/sys_info_v2/gatherer/src/debug/build/native
mkdir -p $GATHERER_BUILD_DEST
NVTOP_SRC=$GATHERER_BUILD_DEST/nvtop-src
cp -r --no-preserve=mode,ownership "${nvtop}" $NVTOP_SRC
pushd $NVTOP_SRC
mkdir -p include/libdrm
for patchfile in $(ls $SRC_GATHERER_NVTOP/patches/nvtop*.patch); do
patch -p1 < $patchfile
done
popd
patchShebangs data/hwdb/generate_hwdb.py
'';
nativeInstallCheckInputs = [ nativeInstallCheckInputs = [
versionCheckHook versionCheckHook
]; ];
versionCheckProgram = "${builtins.placeholder "out"}/bin/${meta.mainProgram}"; versionCheckProgram = "${builtins.placeholder "out"}/bin/missioncenter";
doInstallCheck = true; doInstallCheck = true;
env = { postFixup = ''
# Make sure libGL and libvulkan can be found by dlopen() wrapProgram $out/bin/missioncenter-magpie \
RUSTFLAGS = toString ( --prefix LD_LIBRARY_PATH : "${
map (flag: "-C link-arg=" + flag) [ lib.makeLibraryPath [
"-Wl,--push-state,--no-as-needed" # Make sure libGL libvulkan can be found by dlopen()
"-lGL" libGL
"-lvulkan" vulkan-loader
"-Wl,--pop-state"
] ]
); }"
}; '';
meta = { meta = {
description = "Monitor your CPU, Memory, Disk, Network and GPU usage"; description = "Monitor your CPU, Memory, Disk, Network and GPU usage";
homepage = "https://gitlab.com/mission-center-devs/mission-center"; homepage = "https://gitlab.com/mission-center-devs/mission-center";
changelog = "https://gitlab.com/mission-center-devs/mission-center/-/releases/v${version}"; changelog = "https://gitlab.com/mission-center-devs/mission-center/-/releases/v${finalAttrs.version}";
license = lib.licenses.gpl3Only; license = lib.licenses.gpl3Only;
maintainers = with lib.maintainers; [ maintainers = with lib.maintainers; [
GaetanLepage GaetanLepage
@ -175,4 +193,4 @@ stdenv.mkDerivation rec {
platforms = lib.platforms.linux; platforms = lib.platforms.linux;
mainProgram = "missioncenter"; mainProgram = "missioncenter";
}; };
} })