-
-
Notifications
You must be signed in to change notification settings - Fork 17.7k
btop: Security wrapper add cap perfmon+ep #474935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
btop: Security wrapper add cap perfmon+ep #474935
Conversation
dd security.wrapper.capabilities="cap_perfmon+ep" via programs.btop.enable
nixos/modules/programs/btop.nix
Outdated
| { | ||
| options = { | ||
| programs.btop = { | ||
| enable = lib.mkEnableOption "a setcap wrapper for btop"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need a mkPackageOption as variants like btop-cuda and btop-rocm exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Aleksanaa can you check now , minor change .
I also thought it would be better if it auto selected the package based on GPU , but i don't know how . I could use cudaSupport and rocmSupport variables and decide based on them , it requires multiple if conditions . Or i could filter out lspci outputs and then decide on btop variant, but that like a over complicated hack. And i didn't find anyone using such methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you still need to mention that it applies in some cases and not in others, e.g. enabling this on amd cpu is of no use and btop-rocm should be used. You can probably refer to the source code to see exactly which cases are useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you still need to mention that it applies in some cases and not in others, e.g. enabling this on amd cpu is of no use and
btop-rocmshould be used. You can probably refer to the source code to see exactly which cases are useful.
It's useless then , since it only fixes for intel GPU . Having it under programs is also of no use , these options generally remove that extra step in setting them up.
What do you suggest :
- Should there be another package for intel only , something like btop-intel.
- Should this enable all options ( set wrapper + cudaSupport + rcomSupport ) so , it work anyway.
- Or Maybe there can be a package like btop-full with all options.
- Smart way that somehow select appropriate package and options for their config.
- Or just have separate options like programs.btop.{ intel / amd / nvidia }.
??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- It requires SUID bit on Intel which cannot exist in Nix store thus you cannot achieve this by adding a package.
- I don't know what other situations would require it, this is where I say you should do your research.
- This does not apply to AMD users. AMD users only need to install
btop-rocmand then, it works, no other settings are required. And your method doesn't work for them either. In accordance with the principle of least privilege and to avoid confusing users, you should remind users of its scope.
Could you elaborate more on that? Is it only for CPU wattage and Intel GPU wattage? I'm using an AMD CPU with integrated GPU and GPU wattage does show up but CPU doesn't. |
i only have a intel cpu with iGPU , so i can't tell weather it will work , it does fix not showing gpu usage. i found this issues |
|
@Aleksanaa do you have pkg.rocm-smi installed |
I've installed your wrapper locally. The left is btop with the wrapper and the right is without. Both are normal variant, not
This is the
I don't, but we have it linked in |
Co-authored-by: Aleksana <[email protected]>
507d327 to
50a89c8
Compare
|
@Aleksanaa are you using these overrides : |
Yes although it's called btop-rocm. But I have also tested the normal variant, and they are the same as what I said above, and I don’t see any difference. |


Summary
This PR adds a small NixOS module that provides an optional
security.wrapperssetup forbtop, granting it thecap_perfmoncapability when explicitly enabled.btopcan display CPU and GPU performance counters via Linux perf events, but on NixOS this functionality is unavailable by default because the binary lacks the required capability. Users currently have to either runbtopas root or manually applysetcap, which is impermanent and non-declarative.This module offers a declarative, opt-in solution that aligns with NixOS security practices by:
The module does not change default behavior; it only takes effect when
programs.btop.enable = trueis set.Things done
Built on platform:
Tested, as applicable:
passthru.testsRan
nixpkgs-reviewon this PRTested basic functionality of the wrapped binary (
btop):Nixpkgs Release Notes
NixOS Release Notes
Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md, and related guidelines
Notes for reviewers
cap_perfmonis required for access to perf events used bybtopfor detailed CPU and GPU metrics.