nvtopPackages.apple: darwin support (#356326)

This commit is contained in:
Masum Reza 2024-11-21 23:32:33 +05:30 committed by GitHub
commit 4e7bbd80cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 75 additions and 37 deletions

View File

@ -1,29 +1,37 @@
{ lib {
, stdenv lib,
, fetchFromGitHub stdenv,
, cmake fetchFromGitHub,
, gtest cmake,
, cudatoolkit gtest,
, libdrm cudatoolkit,
, ncurses libdrm,
, testers ncurses,
, udev testers,
, addDriverRunpath udev,
, amd ? false apple-sdk_12,
, intel ? false addDriverRunpath,
, msm ? false amd ? false,
, nvidia ? false intel ? false,
, apple ? false msm ? false,
, panfrost ? false nvidia ? false,
, panthor ? false apple ? false,
, ascend ? false panfrost ? false,
panthor ? false,
ascend ? false,
}: }:
let let
drm-postFixup = '' drm-postFixup = ''
patchelf \ patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "${lib.makeLibraryPath [ libdrm ncurses udev ]}" \ --set-rpath "${
lib.makeLibraryPath [
libdrm
ncurses
udev
]
}" \
$out/bin/nvtop $out/bin/nvtop
''; '';
needDrm = (amd || msm || panfrost || panthor); needDrm = (amd || msm || panfrost || panthor);
@ -51,18 +59,25 @@ stdenv.mkDerivation (finalAttrs: {
(cmakeBool "PANTHOR_SUPPORT" panthor) (cmakeBool "PANTHOR_SUPPORT" panthor)
(cmakeBool "ASCEND_SUPPORT" ascend) (cmakeBool "ASCEND_SUPPORT" ascend)
]; ];
nativeBuildInputs = [ cmake gtest ] ++ lib.optional nvidia addDriverRunpath; nativeBuildInputs = [
cmake
gtest
] ++ lib.optional nvidia addDriverRunpath;
buildInputs = [ ncurses udev ] buildInputs =
[ ncurses ]
++ lib.optional stdenv.isLinux udev
++ lib.optional stdenv.isDarwin apple-sdk_12
++ lib.optional nvidia cudatoolkit ++ lib.optional nvidia cudatoolkit
++ lib.optional needDrm libdrm ++ lib.optional needDrm libdrm;
;
# this helps cmake to find <drm.h> # this helps cmake to find <drm.h>
env.NIX_CFLAGS_COMPILE = lib.optionalString needDrm "-isystem ${lib.getDev libdrm}/include/libdrm"; env.NIX_CFLAGS_COMPILE = lib.optionalString needDrm "-isystem ${lib.getDev libdrm}/include/libdrm";
# ordering of fixups is important # ordering of fixups is important
postFixup = (lib.optionalString needDrm drm-postFixup) + (lib.optionalString nvidia "addDriverRunpath $out/bin/nvtop"); postFixup =
(lib.optionalString needDrm drm-postFixup)
+ (lib.optionalString nvidia "addDriverRunpath $out/bin/nvtop");
doCheck = true; doCheck = true;
@ -83,8 +98,13 @@ stdenv.mkDerivation (finalAttrs: {
homepage = "https://github.com/Syllo/nvtop"; homepage = "https://github.com/Syllo/nvtop";
changelog = "https://github.com/Syllo/nvtop/releases/tag/${finalAttrs.version}"; changelog = "https://github.com/Syllo/nvtop/releases/tag/${finalAttrs.version}";
license = licenses.gpl3Only; license = licenses.gpl3Only;
platforms = platforms.linux; platforms = lib.optional (!apple) platforms.linux ++ lib.optional apple platforms.darwin;
maintainers = with maintainers; [ willibutz gbtb anthonyroussel ]; maintainers = with maintainers; [
willibutz
gbtb
anthonyroussel
moni
];
mainProgram = "nvtop"; mainProgram = "nvtop";
}; };
}) })

View File

@ -1,18 +1,36 @@
{ callPackage }: { callPackage, stdenv }:
let let
# this GPU families are supported "by-default" upstream (see https://github.com/Syllo/nvtop/blob/3a69c2d060298cd6f92cb09db944eded98be1c23/CMakeLists.txt#L81) # this GPU families are supported "by-default" upstream (see https://github.com/Syllo/nvtop/blob/3a69c2d060298cd6f92cb09db944eded98be1c23/CMakeLists.txt#L81)
# coincidentally, these families are also easy to build in nixpkgs at the moment # coincidentally, these families are also easy to build in nixpkgs at the moment
defaultGPUFamilies = [ "amd" "intel" "msm" "nvidia" "panfrost" "panthor" ]; defaultGPUFamilies = [
"amd"
"apple"
"intel"
"msm"
"nvidia"
"panfrost"
"panthor"
];
# these GPU families are partially supported upstream, they are also tricky to build in nixpkgs # these GPU families are partially supported upstream, they are also tricky to build in nixpkgs
# volunteers with specific hardware needed to build and test these package variants # volunteers with specific hardware needed to build and test these package variants
additionalGPUFamilies = [ "apple" "ascend" ]; additionalGPUFamilies = [ "ascend" ];
defaultSupport = builtins.listToAttrs (builtins.map (gpu: { name = gpu; value = true; }) defaultGPUFamilies); defaultSupport = builtins.listToAttrs (
# apple can only build on darwin, and it can't build everything else, and vice versa
builtins.map (gpu: {
name = gpu;
value =
(gpu == "apple" && stdenv.buildPlatform.isDarwin && stdenv.hostPlatform == stdenv.buildPlatform)
|| (gpu != "apple" && stdenv.buildPlatform.isLinux);
}) defaultGPUFamilies
);
in in
{ {
full = callPackage ./build-nvtop.nix defaultSupport; # this package supports all default GPU families full = callPackage ./build-nvtop.nix defaultSupport; # this package supports all default GPU families
} }
# additional packages with only one specific GPU family support # additional packages with only one specific GPU family support
// builtins.listToAttrs (builtins.map (gpu: { name = gpu; value = (callPackage ./build-nvtop.nix { "${gpu}" = true; }); }) defaultGPUFamilies) // builtins.listToAttrs (
builtins.map (gpu: {
name = gpu;
value = (callPackage ./build-nvtop.nix { "${gpu}" = true; });
}) defaultGPUFamilies
)

View File

@ -10524,7 +10524,7 @@ with pkgs;
nvidia-system-monitor-qt = libsForQt5.callPackage ../tools/system/nvidia-system-monitor-qt { }; nvidia-system-monitor-qt = libsForQt5.callPackage ../tools/system/nvidia-system-monitor-qt { };
nvtopPackages = recurseIntoAttrs (import ../tools/system/nvtop { inherit callPackage; }); nvtopPackages = recurseIntoAttrs (import ../tools/system/nvtop { inherit callPackage stdenv; });
inherit (callPackages ../development/libraries/ogre { }) inherit (callPackages ../development/libraries/ogre { })
ogre_13 ogre_14; ogre_13 ogre_14;