Skip to content

Commit 37cf6e3

Browse files
committed
nvtopPackages: format
1 parent 84e9fd9 commit 37cf6e3

File tree

2 files changed

+65
-31
lines changed

2 files changed

+65
-31
lines changed

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

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
1-
{ lib
2-
, stdenv
3-
, fetchFromGitHub
4-
, cmake
5-
, gtest
6-
, cudatoolkit
7-
, libdrm
8-
, ncurses
9-
, testers
10-
, udev
11-
, apple-sdk_12
12-
, addDriverRunpath
13-
, amd ? false
14-
, intel ? false
15-
, msm ? false
16-
, nvidia ? false
17-
, apple ? false
18-
, panfrost ? false
19-
, panthor ? false
20-
, 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,
2122
}:
2223

2324
let
2425
drm-postFixup = ''
2526
patchelf \
2627
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
27-
--set-rpath "${lib.makeLibraryPath [ libdrm ncurses udev ]}" \
28+
--set-rpath "${
29+
lib.makeLibraryPath [
30+
libdrm
31+
ncurses
32+
udev
33+
]
34+
}" \
2835
$out/bin/nvtop
2936
'';
3037
needDrm = (amd || msm || panfrost || panthor);
@@ -52,20 +59,25 @@ stdenv.mkDerivation (finalAttrs: {
5259
(cmakeBool "PANTHOR_SUPPORT" panthor)
5360
(cmakeBool "ASCEND_SUPPORT" ascend)
5461
];
55-
nativeBuildInputs = [ cmake gtest ] ++ lib.optional nvidia addDriverRunpath;
62+
nativeBuildInputs = [
63+
cmake
64+
gtest
65+
] ++ lib.optional nvidia addDriverRunpath;
5666

57-
buildInputs = [ ncurses ]
67+
buildInputs =
68+
[ ncurses ]
5869
++ lib.optional stdenv.isLinux udev
5970
++ lib.optional stdenv.isDarwin apple-sdk_12
6071
++ lib.optional nvidia cudatoolkit
61-
++ lib.optional needDrm libdrm
62-
;
72+
++ lib.optional needDrm libdrm;
6373

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

6777
# ordering of fixups is important
68-
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");
6981

7082
doCheck = true;
7183

@@ -87,7 +99,12 @@ stdenv.mkDerivation (finalAttrs: {
8799
changelog = "https://github.com/Syllo/nvtop/releases/tag/${finalAttrs.version}";
88100
license = licenses.gpl3Only;
89101
platforms = platforms.linux ++ platforms.darwin;
90-
maintainers = with maintainers; [ willibutz gbtb anthonyroussel moni ];
102+
maintainers = with maintainers; [
103+
willibutz
104+
gbtb
105+
anthonyroussel
106+
moni
107+
];
91108
mainProgram = "nvtop";
92109
};
93110
})

pkgs/tools/system/nvtop/default.nix

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,35 @@
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" "apple" "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
816
additionalGPUFamilies = [ "ascend" ];
917
defaultSupport = builtins.listToAttrs (
1018
# apple can only build on darwin, and it can't build everything else, and vice versa
11-
builtins.map (gpu: { name = gpu; value = (gpu == "apple" && stdenv.buildPlatform.isDarwin && stdenv.hostPlatform == stdenv.buildPlatform) || (gpu != "apple" && stdenv.buildPlatform.isLinux);
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);
1224
}) defaultGPUFamilies
1325
);
1426
in
1527
{
16-
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
1729
}
1830
# additional packages with only one specific GPU family support
19-
// builtins.listToAttrs (builtins.map (gpu: { name = gpu; value = (callPackage ./build-nvtop.nix { "${gpu}" = true; }); }) defaultGPUFamilies)
31+
// builtins.listToAttrs (
32+
builtins.map (gpu: {
33+
name = gpu;
34+
value = (callPackage ./build-nvtop.nix { "${gpu}" = true; });
35+
}) defaultGPUFamilies
36+
)

0 commit comments

Comments
 (0)