diff --git a/pkgs/by-name/mi/mission-center/package.nix b/pkgs/by-name/mi/mission-center/package.nix index 4949b4ea5e38..e6d97bde9a92 100644 --- a/pkgs/by-name/mi/mission-center/package.nix +++ b/pkgs/by-name/mi/mission-center/package.nix @@ -9,10 +9,12 @@ # nativeBuildInputs blueprint-compiler, cargo, + makeWrapper, libxml2, meson, ninja, pkg-config, + protobuf, python3, rustc, wrapGAppsHook4, @@ -28,22 +30,28 @@ glib, graphene, gtk4, - libGL, libadwaita, libdrm, libgbm, pango, sqlite, udev, - vulkan-loader, wayland, + # magpie wrapper + libGL, + vulkan-loader, + versionCheckHook, }: # UPDATE PROCESS: # 1) Get the nvtop commit hash (`source-url` in `nvtop.json`): -# https://gitlab.com/mission-center-devs/mission-center/-/blob/v/src/sys_info_v2/gatherer/3rdparty/nvtop/nvtop.json?ref_type=tags +# - Go to https://gitlab.com/mission-center-devs/mission-center/-/blob/v/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 # 3) Refresh all hashes: # - main `src` @@ -54,32 +62,67 @@ let nvtop = fetchFromGitHub { owner = "Syllo"; repo = "nvtop"; - rev = "20ea55dbd1eeb4342ff0112fae3ee2a0bfe352ea"; - hash = "sha256-8lNvxmNAqkmBPFeiYIGtpW0hYXA9N0l4HURew5loj+g="; + rev = "73291884d926445e499d6b9b71cb7a9bdbc7c393"; + hash = "sha256-8iChT55L2NSnHg8tLIry0rgi/4966MffShE0ib+2ywc="; }; in -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "mission-center"; - version = "0.6.2"; + version = "1.0.2"; src = fetchFromGitLab { owner = "mission-center-devs"; repo = "mission-center"; - rev = "v${version}"; - hash = "sha256-PvHIvWyhGovlLaeHk2WMp3yRz4VxvvINzX1oqkFgVuQ="; + tag = "v${finalAttrs.version}"; + 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 { name = "cargo-vendor-dir"; paths = [ (rustPlatform.fetchCargoVendor { - inherit pname version src; - hash = "sha256-Yd6PlsSo8/yHMF4YdYz1Io4uGniAMyIj2RKy3yK4byU="; + inherit (finalAttrs) pname version src; + hash = "sha256-1Bcxp0EuHbJrLQIb2STLNIL2BM2eOgL8ftx4g1o/JY4="; }) (rustPlatform.fetchCargoVendor { - inherit pname version src; - sourceRoot = "${src.name}/src/sys_info_v2/gatherer"; - hash = "sha256-oUAPJWNElj08jfmsdXz/o2bgzeBQsbm6nWHC8jGN2n0="; + pname = "${finalAttrs.pname}-magpie"; + inherit (finalAttrs) version src; + sourceRoot = "${finalAttrs.src.name}/subprojects/magpie"; + hash = "sha256-ouY9zSQ7csAqPzQrbWGtCTB9ECVBKOUX78K5SiqTTxg="; }) ]; }; @@ -88,14 +131,17 @@ stdenv.mkDerivation rec { blueprint-compiler cargo libxml2 + makeWrapper meson ninja pkg-config python3 + protobuf # for protoc rustPlatform.cargoSetupHook rustc wrapGAppsHook4 ]; + dontUseCmakeConfigure = true; buildInputs = [ appstream-glib @@ -109,64 +155,36 @@ stdenv.mkDerivation rec { glib graphene gtk4 - libGL libadwaita libdrm libgbm pango sqlite udev - vulkan-loader 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 = [ versionCheckHook ]; - versionCheckProgram = "${builtins.placeholder "out"}/bin/${meta.mainProgram}"; + versionCheckProgram = "${builtins.placeholder "out"}/bin/missioncenter"; doInstallCheck = true; - env = { - # Make sure libGL and libvulkan can be found by dlopen() - RUSTFLAGS = toString ( - map (flag: "-C link-arg=" + flag) [ - "-Wl,--push-state,--no-as-needed" - "-lGL" - "-lvulkan" - "-Wl,--pop-state" - ] - ); - }; + postFixup = '' + wrapProgram $out/bin/missioncenter-magpie \ + --prefix LD_LIBRARY_PATH : "${ + lib.makeLibraryPath [ + # Make sure libGL libvulkan can be found by dlopen() + libGL + vulkan-loader + ] + }" + ''; meta = { description = "Monitor your CPU, Memory, Disk, Network and GPU usage"; 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; maintainers = with lib.maintainers; [ GaetanLepage @@ -175,4 +193,4 @@ stdenv.mkDerivation rec { platforms = lib.platforms.linux; mainProgram = "missioncenter"; }; -} +})