Skip to content

Commit 4e7bbd8

Browse files
authored
nvtopPackages.apple: darwin support (#356326)
2 parents e931a9c + 088ac6b commit 4e7bbd8

File tree

3 files changed

+75
-37
lines changed

3 files changed

+75
-37
lines changed

pkgs/tools/system/nvtop/build-nvtop.nix

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
1-
{ lib
2-
, stdenv
3-
, fetchFromGitHub
4-
, cmake
5-
, gtest
6-
, cudatoolkit
7-
, libdrm
8-
, ncurses
9-
, testers
10-
, udev
11-
, addDriverRunpath
12-
, amd ? false
13-
, intel ? false
14-
, msm ? false
15-
, nvidia ? false
16-
, apple ? false
17-
, panfrost ? false
18-
, panthor ? false
19-
, ascend ? false
1+
{
2+
lib,
3+
stdenv,
4+
fetchFromGitHub,
5+
cmake,
6+
gtest,
7+
cudatoolkit,
8+
libdrm,
9+
ncurses,
10+
testers,
11+
udev,
12+
apple-sdk_12,
13+
addDriverRunpath,
14+
amd ? false,
15+
intel ? false,
16+
msm ? false,
17+
nvidia ? false,
18+
apple ? false,
19+
panfrost ? false,
20+
panthor ? false,
21+
ascend ? false,
2022
}:
2123

2224
let
2325
drm-postFixup = ''
2426
patchelf \
2527
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
26-
--set-rpath "${lib.makeLibraryPath [ libdrm ncurses udev ]}" \
28+
--set-rpath "${
29+
lib.makeLibraryPath [
30+
libdrm
31+
ncurses
32+
udev
33+
]
34+
}" \
2735
$out/bin/nvtop
2836
'';
2937
needDrm = (amd || msm || panfrost || panthor);
@@ -51,18 +59,25 @@ stdenv.mkDerivation (finalAttrs: {
5159
(cmakeBool "PANTHOR_SUPPORT" panthor)
5260
(cmakeBool "ASCEND_SUPPORT" ascend)
5361
];
54-
nativeBuildInputs = [ cmake gtest ] ++ lib.optional nvidia addDriverRunpath;
62+
nativeBuildInputs = [
63+
cmake
64+
gtest
65+
] ++ lib.optional nvidia addDriverRunpath;
5566

56-
buildInputs = [ ncurses udev ]
67+
buildInputs =
68+
[ ncurses ]
69+
++ lib.optional stdenv.isLinux udev
70+
++ lib.optional stdenv.isDarwin apple-sdk_12
5771
++ lib.optional nvidia cudatoolkit
58-
++ lib.optional needDrm libdrm
59-
;
72+
++ lib.optional needDrm libdrm;
6073

6174
# this helps cmake to find <drm.h>
6275
env.NIX_CFLAGS_COMPILE = lib.optionalString needDrm "-isystem ${lib.getDev libdrm}/include/libdrm";
6376

6477
# ordering of fixups is important
65-
postFixup = (lib.optionalString needDrm drm-postFixup) + (lib.optionalString nvidia "addDriverRunpath $out/bin/nvtop");
78+
postFixup =
79+
(lib.optionalString needDrm drm-postFixup)
80+
+ (lib.optionalString nvidia "addDriverRunpath $out/bin/nvtop");
6681

6782
doCheck = true;
6883

@@ -83,8 +98,13 @@ stdenv.mkDerivation (finalAttrs: {
8398
homepage = "https://github.com/Syllo/nvtop";
8499
changelog = "https://github.com/Syllo/nvtop/releases/tag/${finalAttrs.version}";
85100
license = licenses.gpl3Only;
86-
platforms = platforms.linux;
87-
maintainers = with maintainers; [ willibutz gbtb anthonyroussel ];
101+
platforms = lib.optional (!apple) platforms.linux ++ lib.optional apple platforms.darwin;
102+
maintainers = with maintainers; [
103+
willibutz
104+
gbtb
105+
anthonyroussel
106+
moni
107+
];
88108
mainProgram = "nvtop";
89109
};
90110
})
Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,36 @@
1-
{ callPackage }:
1+
{ callPackage, stdenv }:
22
let
33
# this GPU families are supported "by-default" upstream (see https://github.com/Syllo/nvtop/blob/3a69c2d060298cd6f92cb09db944eded98be1c23/CMakeLists.txt#L81)
44
# coincidentally, these families are also easy to build in nixpkgs at the moment
5-
defaultGPUFamilies = [ "amd" "intel" "msm" "nvidia" "panfrost" "panthor" ];
5+
defaultGPUFamilies = [
6+
"amd"
7+
"apple"
8+
"intel"
9+
"msm"
10+
"nvidia"
11+
"panfrost"
12+
"panthor"
13+
];
614
# these GPU families are partially supported upstream, they are also tricky to build in nixpkgs
715
# volunteers with specific hardware needed to build and test these package variants
8-
additionalGPUFamilies = [ "apple" "ascend" ];
9-
defaultSupport = builtins.listToAttrs (builtins.map (gpu: { name = gpu; value = true; }) defaultGPUFamilies);
16+
additionalGPUFamilies = [ "ascend" ];
17+
defaultSupport = builtins.listToAttrs (
18+
# apple can only build on darwin, and it can't build everything else, and vice versa
19+
builtins.map (gpu: {
20+
name = gpu;
21+
value =
22+
(gpu == "apple" && stdenv.buildPlatform.isDarwin && stdenv.hostPlatform == stdenv.buildPlatform)
23+
|| (gpu != "apple" && stdenv.buildPlatform.isLinux);
24+
}) defaultGPUFamilies
25+
);
1026
in
1127
{
12-
full = callPackage ./build-nvtop.nix defaultSupport; #this package supports all default GPU families
28+
full = callPackage ./build-nvtop.nix defaultSupport; # this package supports all default GPU families
1329
}
1430
# additional packages with only one specific GPU family support
15-
// builtins.listToAttrs (builtins.map (gpu: { name = gpu; value = (callPackage ./build-nvtop.nix { "${gpu}" = true; }); }) defaultGPUFamilies)
16-
17-
18-
31+
// builtins.listToAttrs (
32+
builtins.map (gpu: {
33+
name = gpu;
34+
value = (callPackage ./build-nvtop.nix { "${gpu}" = true; });
35+
}) defaultGPUFamilies
36+
)

pkgs/top-level/all-packages.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10524,7 +10524,7 @@ with pkgs;
1052410524

1052510525
nvidia-system-monitor-qt = libsForQt5.callPackage ../tools/system/nvidia-system-monitor-qt { };
1052610526

10527-
nvtopPackages = recurseIntoAttrs (import ../tools/system/nvtop { inherit callPackage; });
10527+
nvtopPackages = recurseIntoAttrs (import ../tools/system/nvtop { inherit callPackage stdenv; });
1052810528

1052910529
inherit (callPackages ../development/libraries/ogre { })
1053010530
ogre_13 ogre_14;

0 commit comments

Comments
 (0)