Nix Monitor

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

View the Project on GitHub antonjah/nix-monitor

Nix Monitor

A DankMaterialShell plugin for monitoring Nix store disk usage and system generations with integrated system management capabilities.

Features

Bar Widget Display

Detailed Popout Panel

Click the widget to open a detailed view with:

Configurable Settings

Access via DMS Settings → Plugins → Nix Monitor:

Installation

As a Flake Input

For NixOS System Configuration

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"
            ];
          };
        }
      ];
    };
  };
}

For home-manager Configuration

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"
            ];
          };
        }
      ];
    };
  };
}

Activation

For NixOS

  1. Rebuild your NixOS configuration: sudo nixos-rebuild switch --flake .#hostname
  2. Restart DMS: dms restart
  3. Open DMS Settings → Plugins
  4. Click “Scan for Plugins”
  5. Toggle “Nix Monitor” ON
  6. Add to your DankBar layout

For home-manager

  1. Rebuild your home-manager configuration: home-manager switch --flake .#home
  2. Restart DMS: dms restart
  3. Open DMS Settings → Plugins
  4. Click “Scan for Plugins”
  5. Toggle “Nix Monitor” ON
  6. Add to your DankBar layout

Updating

For NixOS

After updating the plugin:

nix flake update nix-monitor
sudo nixos-rebuild switch --flake .#hostname
rm -rf ~/.cache/quickshell/qmlcache/
dms restart

For home-manager

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.

Usage

Bar Widget

Popout Panel

Console Output

Configuration

The plugin provides sensible defaults for NixOS system monitoring, but rebuildCommand is required and must be configured for your specific setup.

Default Commands

If not overridden, the plugin uses these NixOS defaults:

Note: rebuildCommand has no default and must be explicitly configured because rebuild commands vary significantly between:

NixOS Module Example (Minimal)

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"
  ];
};

NixOS Module Example (Full Customization)

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;
};

home-manager Module Example (Minimal)

programs.nix-monitor = {
  enable = true;
  
  # Required: customize for your setup
  rebuildCommand = [ 
    "bash" "-c" 
    "cd ~/.config/home-manager && home-manager switch --flake .#home 2>&1"
  ];
};

home-manager Module Example (Full Customization)

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;
};

Configuration Options

Both NixOS and home-manager modules use the same programs.nix-monitor namespace with identical options.

Required:

Optional (with defaults):

Requirements

License

MIT

Author

Anton Andersson (@antonjah)