danth / stylix

System-wide colorscheming and typography for NixOS
https://stylix.danth.me/
MIT License
906 stars 105 forks source link

Mangohud breaks when enabling stylix's mangohud module #298

Closed NovaViper closed 2 months ago

NovaViper commented 3 months ago

I'm not sure exactly why, but I notice mangohud just completely stops working when I let stylix modify its theme. I get an error like this when I run goverlay (settings manager for MangoHud)

❯ goverlay
[2024-03-21 14:21:21.316] [MANGOHUD] [error] [overlay_params.cpp:1003] Failed to read presets file: '/home/novaviper/.config/MangoHud/presets.conf'
[2024-03-21 14:21:21.348] [MANGOHUD] [error] [loader_nvml.cpp:42] Failed to open 64bit libnvidia-ml.so.1: libnvidia-ml.so.1: cannot open shared object file: No such file or directory
[2024-03-21 14:21:21.348] [MANGOHUD] [error] [nvml.cpp:45] Failed to load NVML
[2024-03-21 14:21:21.348] [MANGOHUD] [error] [loader_nvctrl.cpp:39] Failed to open 64bit libXNVCtrl.so.0: libXNVCtrl.so.0: cannot open shared object file: No such file or directory
[2024-03-21 14:21:21.348] [MANGOHUD] [error] [nvctrl.cpp:48] XNVCtrl loader failed to load
[2024-03-21 14:21:22.863] [MANGOHUD] [error] [nvml.cpp:45] Failed to load NVML
[2024-03-21 14:21:22.863] [MANGOHUD] [error] [nvctrl.cpp:48] XNVCtrl loader failed to load
paint
goverlay: ../subprojects/imgui-1.89.9/imgui.cpp:9197: void ImGui::ErrorCheckNewFrameSanityChecks(): Assertion `g.IO.Fonts->IsBuilt() && "Font Atlas not built! Make sure you called ImGui_ImplXXXX_NewFrame() function for renderer backend, which should call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8()"' failed.
/home/novaviper/.nix-profile/bin/goverlay: line 9: 153520 Aborted                 (core dumped) mangohud --dlsym /nix/store/36b9nmbihwvr5bsfzngnjshxs8lcvvbp-goverlay-0.7.1/libexec/goverlay --style Breeze

I already have some settings configured for mangohud included with my flake (with the colors commented out so it doesn't conflict), and these settings work just fine prior to using stylix. Mangohud settings before using Stylix

cpu_load_change
cpu_load_color=39F900,FDFD09,B22222
cpu_load_value=60,90
cpu_stats
cpu_temp
fps
frame_timing
frametime
gpu_load_change
gpu_load_color=39F900,FDFD09,B22222
gpu_load_value=60,90
gpu_stats
gpu_temp
output_folder=/home/novaviper/.local/state/mangologs
ram
show_fps_limit
text_outline
throttling_status
toggle_hud=Shift_R+F12
toggle_logging=Shift_L+F2
vram

MangoHud settings after using Stylix

alpha=1.000000
background_alpha=1.000000
background_color=1e1e2e
battery_color=585b70
cpu_color=89b4fa
cpu_load_change
cpu_load_color=a6e3a1, f9e2af, f38ba8
cpu_stats
cpu_temp
engine_color=cba6f7
font_file=/nix/store/sskwj7av3gv6n5hl7r0zx8w7jhj3wa64-mangohud-stylix.ttf
font_scale=1.333330
font_size=10
font_size_text=10
fps
fps_color=a6e3a1, f9e2af, f38ba8
frame_timing
frametime
frametime_color=a6e3a1
gpu_color=a6e3a1
gpu_load_change
gpu_load_color=a6e3a1, f9e2af, f38ba8
gpu_stats
gpu_temp
io_color=f9e2af
media_player_color=cdd6f4
output_folder=/home/novaviper/.local/state/mangologs
ram
show_fps_limit
text_color=cdd6f4
text_outline
text_outline_color=1e1e2e
throttling_status
toggle_hud=Shift_R+F12
toggle_logging=Shift_L+F2
vram
vram_color=94e2d5
wine_color=cba6f7

Stylix settings

  stylix = {
    autoEnable = true;
    image = "${inputs.wallpapers}/purple-mountains-ai.png";
    base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-mocha.yaml";
    #polarity = "dark";
    cursor = {
      package = pkgs.capitaine-cursors;
      name = "capitaine-cursors-white";
      size = 32;
    };
    fonts = rec {
      sansSerif = {
        package = pkgs.cantarell-fonts;
        name = "Cantarell";
      };
      serif = sansSerif;
      monospace = {
        package = pkgs.meslo-lgs-nf;
        name = "MesloLGS Nerd Font";
      };
      emoji = {
        package = pkgs.noto-fonts-emoji;
        name = "Noto Color Emoji";
      };
      sizes = {
        applications = 10;
        desktop = 10;
        popups = 10;
        terminal = 11;
      };
    };
    targets = {
      kitty.variant256Colors = true;
      emacs.enable = false;
      #mangohud.enable = false;
    };
  };

NixOS info:

❯ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.8.1, NixOS, 24.05 (Uakari), 24.05.20240316.c75037b`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.2`
 - nixpkgs: `/nix/store/7ay2dd0w41iqvrnkx19v4vf4f5kkxvc2-source`
trueNAHO commented 3 months ago

MangoHud settings after using Stylix

[...]

font_file=/nix/store/sskwj7av3gv6n5hl7r0zx8w7jhj3wa64-mangohud-stylix.ttf

This line is oddly Nix-specific and generated by https://github.com/danth/stylix/blob/a38d900ddf2c65658cd242afdee90c3ec2d6b810/modules/mangohud/hm.nix#L7-L15 at https://github.com/danth/stylix/blob/a38d900ddf2c65658cd242afdee90c3ec2d6b810/modules/mangohud/hm.nix#L21 Does MangoHud work when manually removing this font_file line:

# This here is only an example workflow to edit the Nix-generated '$FILE' file.
mv "$FILE" "${FILE}.bak"
cp --dereference "${FILE}.bak" "$FILE"
$EDITOR "$FILE"

these settings work just fine prior to using stylix

If removing the font_file line does not resolve the issue, does reverting https://github.com/danth/stylix/commit/a38d900ddf2c65658cd242afdee90c3ec2d6b810 do so?

NovaViper commented 3 months ago

Does MangoHud work when manually removing this font_file line:

Removing the line made Mangohud work again!

trueNAHO commented 3 months ago

cc: @RANKSHANK, https://github.com/danth/stylix/pull/260

The following code snippets are causing MangoHud issues:

RANKSHANK commented 3 months ago

I was able to reproduce this, however I had to switch to Cantarell.

So far I've found:

Does anyone have other non working fonts? I've sucessfully run Ubuntu, Liberation, Roboto, Fira, Monaspace, JetBrains, Carlito, and Comic Relief.

NovaViper commented 3 months ago

🤔 Oddly I'm using that same font and it still didn't work @RANKSHANK

trueNAHO commented 3 months ago

As a non-MangoHud user I do not have the bandwidth to properly implement the fix. Any help would be greatly appreciated.

For reference, https://github.com/danth/stylix/issues/308 acts as a tracking issue.

trueNAHO commented 3 months ago

Related:

trueNAHO commented 2 months ago

Closed by https://github.com/danth/stylix/pull/307 and tracked at https://github.com/danth/stylix/issues/308.