Fix waybar Nvidia module

This commit is contained in:
Bun 2025-05-12 11:19:54 -04:00
parent f50b90ba94
commit a791dd0583
5 changed files with 20 additions and 10 deletions

View file

@ -57,7 +57,10 @@
specialArgs = inputs; specialArgs = inputs;
}; };
mkHome = extraModules: hm.lib.homeManagerConfiguration { mkHome = extraModules: hm.lib.homeManagerConfiguration {
modules = [ ./modules/home ] ++ extraModules; modules = [
./modules/home
{ targets.genericLinux.enable = true; }
] ++ extraModules;
extraSpecialArgs = inputs; extraSpecialArgs = inputs;
pkgs = builtins.getAttr system stable.legacyPackages; pkgs = builtins.getAttr system stable.legacyPackages;
}; };
@ -79,12 +82,6 @@
homeConfigurations = { homeConfigurations = {
default = mkHome [ ]; default = mkHome [ ];
desktop = mkHome [{ home.guifull.enable = true; }]; desktop = mkHome [{ home.guifull.enable = true; }];
generic = mkHome [{ targets.genericLinux.enable = true; }];
genericDesktop = mkHome [{
home.guifull.enable = true;
targets.genericLinux.enable = true;
}];
}; };
} }
); );

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }: { config, lib, pkgsUnstable, ... }:
let let
commonKernelParams = [ commonKernelParams = [
# VM/GPU passthrough # VM/GPU passthrough
@ -13,7 +13,7 @@ let
in { in {
boot = { boot = {
# Latest kernel and IOMMU isolation # Latest kernel and IOMMU isolation
kernelPackages = pkgs.linuxPackages_latest; kernelPackages = pkgsUnstable.linuxPackages_latest;
kernelParams = commonKernelParams ++ [ "vfio-pci.ids=10de:1f82,10de:10fa" ]; kernelParams = commonKernelParams ++ [ "vfio-pci.ids=10de:1f82,10de:10fa" ];
# Load into GPU before video driver # Load into GPU before video driver

View file

@ -61,6 +61,7 @@
BC="${bc}/bin/bc" BC="${bc}/bin/bc"
HEAD="${uutils-coreutils-noprefix}/bin/head" HEAD="${uutils-coreutils-noprefix}/bin/head"
CAT="${uutils-coreutils-noprefix}/bin/cat" CAT="${uutils-coreutils-noprefix}/bin/cat"
NVIDIA="/run/current-system/sw/bin/nvidia-smi"
# Detect the active GPU driver # Detect the active GPU driver
gpu_driver="$($LSPCI -k | $GREP -Eo 'in use: (nvidia|amdgpu)' | $AWK '{print $3}')" gpu_driver="$($LSPCI -k | $GREP -Eo 'in use: (nvidia|amdgpu)' | $AWK '{print $3}')"
@ -72,7 +73,7 @@
# Get VRAM usage in MB # Get VRAM usage in MB
if [[ "$gpu_driver" == "nvidia" ]]; then if [[ "$gpu_driver" == "nvidia" ]]; then
vram_usage_mb="$(nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits | $HEAD -n1)" vram_usage_mb="$($NVIDIA --query-gpu=memory.used --format=csv,noheader,nounits | $HEAD -n1)"
elif [[ "$gpu_driver" == "amdgpu" ]]; then elif [[ "$gpu_driver" == "amdgpu" ]]; then
vram_bytes="$($CAT /sys/class/drm/card*/device/mem_info_vram_used 2>/dev/null | $HEAD -n1)" vram_bytes="$($CAT /sys/class/drm/card*/device/mem_info_vram_used 2>/dev/null | $HEAD -n1)"
vram_usage_mb="$($BC <<< "$vram_bytes / 1024 / 1024")" vram_usage_mb="$($BC <<< "$vram_bytes / 1024 / 1024")"

View file

@ -0,0 +1,11 @@
{ config, pkgs, stable, unstable, ... }:
with pkgs; {
_module.args.pkgsStable = import stable {
inherit (stdenv.hostPlatform) system;
inherit (config.nixpkgs) config;
};
_module.args.pkgsUnstable = import unstable {
inherit (stdenv.hostPlatform) system;
inherit (config.nixpkgs) config;
};
}

View file

@ -1,6 +1,7 @@
{ pkgs, ... }: { pkgs, ... }:
{ {
imports = [ imports = [
./channels
./gc ./gc
./unfree ./unfree
]; ];