mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-11 14:49:23 +08:00
flake: update btop
This commit is contained in:
6
flake.lock
generated
6
flake.lock
generated
@@ -1144,11 +1144,11 @@
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1767053975,
|
||||
"narHash": "sha256-Zt1zWeJw0d2irAgC3lOfGgcAlDEUEzWG4kHV6BVhbqY=",
|
||||
"lastModified": 1767223621,
|
||||
"narHash": "sha256-Q0vXLCj8m9i87XfoyhKkHNIq8hjoNKEoysxU6uS+6o4=",
|
||||
"owner": "CHN-beta",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9a8b7c7d8195a2dd2bf130bdcf3326f0d21e827b",
|
||||
"rev": "1768cfa9daffab526e6573114c4c94353ee49d80",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
76
flake/lib/buildNixpkgsConfig/btop.patch
Normal file
76
flake/lib/buildNixpkgsConfig/btop.patch
Normal file
@@ -0,0 +1,76 @@
|
||||
diff --git a/src/btop_config.cpp b/src/btop_config.cpp
|
||||
index eaaa577..3074a08 100644
|
||||
--- a/src/btop_config.cpp
|
||||
+++ b/src/btop_config.cpp
|
||||
@@ -234,6 +234,7 @@ namespace Config {
|
||||
{"custom_gpu_name4", "#* Custom gpu4 model name, empty string to disable."},
|
||||
{"custom_gpu_name5", "#* Custom gpu5 model name, empty string to disable."},
|
||||
#endif
|
||||
+ {"btrfs_group_subvolumes", "#* Show only the first subvolume of a btrfs filesystem."},
|
||||
};
|
||||
|
||||
std::unordered_map<std::string_view, string> strings = {
|
||||
@@ -336,6 +337,7 @@ namespace Config {
|
||||
#endif
|
||||
{"terminal_sync", true},
|
||||
- {"save_config_on_exit", true}
|
||||
+ {"save_config_on_exit", true},
|
||||
+ {"btrfs_group_subvolumes", false},
|
||||
};
|
||||
std::unordered_map<std::string_view, bool> boolsTmp;
|
||||
|
||||
diff --git a/src/btop_menu.cpp b/src/btop_menu.cpp
|
||||
index 75ec31c..cfaec39 100644
|
||||
--- a/src/btop_menu.cpp
|
||||
+++ b/src/btop_menu.cpp
|
||||
@@ -724,6 +724,15 @@ namespace Menu {
|
||||
"kernel as used memory.",
|
||||
"",
|
||||
"True or False."},
|
||||
+ {
|
||||
+ "btrfs_group_subvolumes",
|
||||
+ "(Linux) Show only first BTRFS subvolume.",
|
||||
+ "",
|
||||
+ "Set to true to only show the first BTRFS",
|
||||
+ "subvolume mounted per disk.",
|
||||
+ "",
|
||||
+ "True or False.",
|
||||
+ }
|
||||
},
|
||||
{
|
||||
{"graph_symbol_net",
|
||||
diff --git a/src/linux/btop_collect.cpp b/src/linux/btop_collect.cpp
|
||||
index eebaa50..37d5745 100644
|
||||
--- a/src/linux/btop_collect.cpp
|
||||
+++ b/src/linux/btop_collect.cpp
|
||||
@@ -2117,6 +2117,7 @@ namespace Mem {
|
||||
auto use_fstab = Config::getB("use_fstab");
|
||||
auto only_physical = Config::getB("only_physical");
|
||||
auto zfs_hide_datasets = Config::getB("zfs_hide_datasets");
|
||||
+ auto btrfs_group_subvolumes = Config::getB("btrfs_group_subvolumes");
|
||||
auto& disks = mem.disks;
|
||||
static std::unordered_map<string, future<pair<disk_info, int>>> disks_stats_promises;
|
||||
ifstream diskread;
|
||||
@@ -2177,6 +2178,7 @@ namespace Mem {
|
||||
vector<string> found;
|
||||
found.reserve(last_found.size());
|
||||
string dev, mountpoint, fstype;
|
||||
+ std::unordered_set<string> found_btrfs_subvolumes;
|
||||
while (not diskread.eof()) {
|
||||
std::error_code ec;
|
||||
diskread >> dev >> mountpoint >> fstype;
|
||||
@@ -2198,6 +2200,14 @@ namespace Mem {
|
||||
size_t zfs_dataset_name_start = 0;
|
||||
if (fstype == "zfs" && (zfs_dataset_name_start = dev.find('/')) != std::string::npos && zfs_hide_datasets) continue;
|
||||
|
||||
+ //? skip BtrFS subvolumes
|
||||
+ if (btrfs_group_subvolumes and fstype == "btrfs") {
|
||||
+ string devname = fs::canonical(dev, ec).filename();
|
||||
+ if (!found_btrfs_subvolumes.insert(devname).second) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if ((not use_fstab and not only_physical)
|
||||
or (use_fstab and v_contains(fstab, mountpoint))
|
||||
or (not use_fstab and only_physical and v_contains(fstypes, fstype))) {
|
||||
@@ -72,6 +72,7 @@ in platformConfig //
|
||||
google-chrome = prev.google-chrome.override (prev:
|
||||
{ commandLineArgs = prev.commandLineArgs or "" + " --disable-features=GlobalShortcutsPortal"; });
|
||||
xray = prev.xray.overrideAttrs (prev: { patches = prev.patches or [] ++ [ ./xray.patch ]; });
|
||||
btop = prev.btop.overrideAttrs (prev: { patches = prev.patches or [] ++ [ ./btop.patch ]; });
|
||||
}
|
||||
// (
|
||||
let
|
||||
|
||||
19
modules/packages/btop.nix
Normal file
19
modules/packages/btop.nix
Normal file
@@ -0,0 +1,19 @@
|
||||
{ lib, pkgs, config, ... }:
|
||||
{
|
||||
options.nixos.packages.btop = lib.mkOption { type = lib.types.nullOr (lib.types.submodule {}); default = {}; };
|
||||
config = let inherit (config.nixos.packages) btop; in lib.mkIf (btop != null)
|
||||
{
|
||||
nixos =
|
||||
{
|
||||
packages.packages._packages = [ pkgs.btop ];
|
||||
user.sharedModules =
|
||||
[{
|
||||
config.programs.btop =
|
||||
{
|
||||
enable = true;
|
||||
settings.btrfs_group_subvolumes = true;
|
||||
};
|
||||
}];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -14,7 +14,7 @@ inputs:
|
||||
# lsxx
|
||||
pciutils usbutils lshw util-linux lsof dmidecode lm_sensors hwloc acpica-tools ethtool
|
||||
# top
|
||||
iotop iftop htop btop powertop s-tui
|
||||
iotop iftop htop powertop s-tui
|
||||
# editor
|
||||
nano bat
|
||||
# downloader
|
||||
|
||||
Reference in New Issue
Block a user