1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-24 02:39:48 +01:00

mangohud: add module

This commit is contained in:
ZerataX 2021-06-12 09:55:58 +02:00
parent 666eee4f72
commit fb50102daf
No known key found for this signature in database
GPG key ID: 8333735E784DF9D4
9 changed files with 174 additions and 1 deletions

5
.github/CODEOWNERS vendored
View file

@ -104,6 +104,9 @@
/modules/programs/matplotlib.nix @rprospero
/modules/programs/mangohud.nix @ZerataX
/tests/modules/programs/mangohud @ZerataX
/modules/programs/mbsync.nix @KarlJoad
/tests/modules/programs/mbsync @KarlJoad
@ -315,4 +318,4 @@
/modules/xresources.nix @rycee
/modules/xsession.nix @rycee
/modules/xsession.nix @rycee

View file

@ -2077,6 +2077,13 @@ in
A new module is available: 'services.pantalaimon'.
'';
}
{
time = "2021-06-12T05:00:22+00:00";
message = ''
A new module is available: 'programs.mangohud'.
'';
}
];
};
}

View file

@ -93,6 +93,7 @@ let
(loadModule ./programs/lf.nix { })
(loadModule ./programs/lsd.nix { })
(loadModule ./programs/man.nix { })
(loadModule ./programs/mangohud.nix { condition = hostPlatform.isLinux; })
(loadModule ./programs/matplotlib.nix { })
(loadModule ./programs/mbsync.nix { })
(loadModule ./programs/mcfly.nix { })

View file

@ -0,0 +1,105 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.mangohud;
settingsType = with types;
(oneOf [ bool int float str path (listOf (oneOf [ int str ])) ]);
renderOption = option:
rec {
int = toString option;
float = int;
path = int;
bool = "false";
string = option;
list = concatStringsSep "," (lists.forEach option (x: toString x));
}.${builtins.typeOf option};
renderLine = k: v: (if isBool v && v then k else "${k}=${renderOption v}");
renderSettings = attrs:
strings.concatStringsSep "\n" (attrsets.mapAttrsToList renderLine attrs)
+ "\n";
in {
options = {
programs.mangohud = {
enable = mkEnableOption "Mangohud";
package = mkOption {
type = types.package;
default = pkgs.mangohud;
defaultText = literalExample "pkgs.mangohud";
description = "The Mangohud package to install.";
};
enableSessionWide = mkOption {
type = types.bool;
default = false;
description = ''
Sets environment variables so that
MangoHud is started on any application that supports it.
'';
};
settings = mkOption {
type = with types; attrsOf settingsType;
default = { };
example = literalExample ''
{
output_folder = ~/Documents/mangohud/;
full = true;
}
'';
description = ''
Configuration written to
<filename>~/.config/MangoHud/MangoHud.conf</filename>. See
<link xlink:href="https://github.com/flightlessmango/MangoHud/blob/master/bin/MangoHud.conf"/>
for the default configuration.
'';
};
settingsPerApplication = mkOption {
type = with types; attrsOf (attrsOf settingsType);
default = { };
example = literalExample ''
{
mpv = {
no_display = true;
}
}
'';
description = ''
Sets MangoHud settings per application.
Configuration written to
<filename>~/.config/MangoHud/{application_name}.conf</filename>. See
<link xlink:href="https://github.com/flightlessmango/MangoHud/blob/master/bin/MangoHud.conf"/>
for the default configuration.
'';
};
};
};
config = mkIf cfg.enable (mkMerge [
{
home.packages = [ cfg.package ];
home.sessionVariables = mkIf cfg.enableSessionWide {
MANGOHUD = 1;
MANGOHUD_DLSYM = 1;
};
xdg.configFile."MangoHud/MangoHud.conf" =
mkIf (cfg.settings != { }) { text = renderSettings cfg.settings; };
}
{
xdg.configFile = mapAttrs'
(n: v: nameValuePair "MangoHud/${n}.conf" { text = renderSettings v; })
cfg.settingsPerApplication;
}
]);
meta.maintainers = with maintainers; [ zeratax ];
}

View file

@ -101,6 +101,7 @@ import nmt {
./modules/programs/foot
./modules/programs/getmail
./modules/programs/i3status-rust
./modules/programs/mangohud
./modules/programs/ncmpcpp-linux
./modules/programs/neovim # Broken package dependency on Darwin.
./modules/programs/rbw

View file

@ -0,0 +1,2 @@
no_display
output_folder=/home/user/Documents/mpv-mangohud

View file

@ -0,0 +1,13 @@
cpu_load_change
cpu_load_value
cpu_mhz
cpu_power
cpu_stats
cpu_temp
cpu_text=CPU
fps_limit=30,60
legacy_layout=false
media_player_name=spotify
media_player_order=title,artist,album
output_folder=/home/user/Documents/mangohud
vsync=0

View file

@ -0,0 +1,40 @@
{ config, pkgs, ... }:
{
config = {
programs.mangohud = {
enable = true;
package = pkgs.writeScriptBin "dummy-mangohud" "";
settings = {
output_folder = /home/user/Documents/mangohud;
fps_limit = [ 30 60 ];
vsync = 0;
legacy_layout = false;
cpu_stats = true;
cpu_temp = true;
cpu_power = true;
cpu_text = "CPU";
cpu_mhz = true;
cpu_load_change = true;
cpu_load_value = true;
media_player_name = "spotify";
media_player_order = [ "title" "artist" "album" ];
};
settingsPerApplication = {
mpv = {
output_folder = /home/user/Documents/mpv-mangohud;
no_display = true;
};
};
};
nmt.script = ''
assertFileExists home-files/.config/MangoHud/MangoHud.conf
assertFileContent home-files/.config/MangoHud/MangoHud.conf \
${./basic-configuration.conf}
assertFileExists home-files/.config/MangoHud/mpv.conf
assertFileContent home-files/.config/MangoHud/mpv.conf \
${./basic-configuration-mpv.conf}
'';
};
}

View file

@ -0,0 +1 @@
{ mangohud-basic-configuration = ./basic-configuration.nix; }