A DankMaterialShell plugin for monitoring Nix store disk usage and system generations

A DankMaterialShell plugin for monitoring Nix store disk usage and system generations with integrated system management capabilities.
Click the widget to open a detailed view with:
Access via DMS Settings → Plugins → Nix Monitor:
Add to your NixOS configuration.nix flake:
{
inputs = {
nix-monitor = {
url = "github:antonjah/nix-monitor";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, nix-monitor, ... }: {
nixosConfigurations.hostname = nixpkgs.lib.nixosSystem {
modules = [
nix-monitor.nixosModules.default
{
programs.nix-monitor = {
enable = true;
# Required: customize for your setup
rebuildCommand = [
"bash" "-c"
"sudo nixos-rebuild switch --flake .#hostname 2>&1"
];
};
}
];
};
};
}
Add to your home-manager flake.nix:
{
inputs = {
nix-monitor = {
url = "github:antonjah/nix-monitor";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, home-manager, nix-monitor, ... }: {
homeConfigurations."youruser" = home-manager.lib.homeManagerConfiguration {
modules = [
nix-monitor.homeManagerModules.default
{
programs.nix-monitor = {
enable = true;
# Required: customize for your setup
rebuildCommand = [
"bash" "-c"
"cd ~/.config/home-manager && home-manager switch --flake .#home 2>&1"
];
};
}
];
};
};
}
sudo nixos-rebuild switch --flake .#hostnamedms restarthome-manager switch --flake .#homedms restartAfter updating the plugin:
nix flake update nix-monitor
sudo nixos-rebuild switch --flake .#hostname
rm -rf ~/.cache/quickshell/qmlcache/
dms restart
After updating the plugin:
nix flake update nix-monitor
home-manager switch --flake .#home
rm -rf ~/.cache/quickshell/qmlcache/
dms restart
Note: Due to QML disk caching with Nix symlinks, you must clear the QML cache after plugin updates for changes to take effect.
nix-collect-garbage -d by default)The plugin provides sensible defaults for NixOS system monitoring, but rebuildCommand is required and must be configured for your specific setup.
If not overridden, the plugin uses these NixOS defaults:
generationsCommand: Lists system generations from /nix/var/nix/profiles/systemstoreSizeCommand: Checks /nix/store disk usage with du -shgcCommand: Runs nix-collect-garbage -dupdateInterval: 300 seconds (5 minutes)Note: rebuildCommand has no default and must be explicitly configured because rebuild commands vary significantly between:
Uses all defaults - only rebuildCommand is required:
programs.nix-monitor = {
enable = true;
# Required: customize for your setup
rebuildCommand = [
"bash" "-c"
"sudo nixos-rebuild switch --flake .#hostname 2>&1"
];
};
programs.nix-monitor = {
enable = true;
rebuildCommand = [
"bash" "-c"
"sudo nixos-rebuild switch --flake .#hostname 2>&1"
];
# Use sudo for garbage collection
gcCommand = [
"bash" "-c"
"sudo nix-collect-garbage -d 2>&1"
];
# Check for updates on the 24.11 stable channel
nixpkgsChannel = "nixos-24.11";
updateInterval = 600;
};
programs.nix-monitor = {
enable = true;
# Required: customize for your setup
rebuildCommand = [
"bash" "-c"
"cd ~/.config/home-manager && home-manager switch --flake .#home 2>&1"
];
};
programs.nix-monitor = {
enable = true;
# Track home-manager generations instead of system generations
generationsCommand = [ "sh" "-c" "home-manager generations 2>/dev/null | wc -l" ];
rebuildCommand = [
"bash" "-c"
"cd ~/.config/home-manager && home-manager switch --flake .#home 2>&1"
];
# Optional: customize other settings
updateInterval = 300;
};
Both NixOS and home-manager modules use the same programs.nix-monitor namespace with identical options.
Required:
rebuildCommand - Command to run for system rebuild (REQUIRED)Optional (with defaults):
generationsCommand - Command to count system generationsnix-env --list-generations --profile /nix/var/nix/profiles/system | wc -lstoreSizeCommand - Command to get Nix store sizedu -sh /nix/store | cut -f1gcCommand - Command to run for garbage collectionnix-collect-garbage -dupdateInterval - Update interval in seconds300 (5 minutes)localRevisionCommand - Command to get local nixpkgs revisionnixos-version --hash | cut -c 1-7remoteRevisionCommand - Command to get remote nixpkgs revisiongit ls-remote https://github.com/NixOS/nixpkgs.git nixos-unstable | cut -c 1-7remoteRevisionCommand = [
"${pkgs.bash}/bin/bash" "-l" "-c"
"${pkgs.curl}/bin/curl -s https://api.github.com/repos/NixOS/nixpkgs/git/ref/heads/nixos-unstable 2>/dev/null | ${pkgs.jq}/bin/jq -r '.object.sha' 2>/dev/null | cut -c 1-7 || echo 'N/A'"
];
nixpkgsChannel - NixOS channel to check for updatesnixos-unstable (Options: nixos-unstable, nixos-24.11, nixos-24.05, nixos-23.11)MIT
Anton Andersson (@antonjah)