fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6cfg = config . programs . mangohud ; 7 8settingsType = with types ; 9( oneOf [ bool int float str path ( listOf ( oneOf [ int str ])) ]); 10 11renderOption = option : 12rec { 13int = toString option ; 14float = int ; 15path = int ; 16bool = "false" ; 17string = option ; 18list = concatStringsSep "," ( lists . forEach option ( x :toString x )); 19}.${ builtins . typeOf option }; 20 21renderLine = k :v :( if isBool v && v then k else " ${ k } = ${ renderOption v } " ); 22renderSettings = attrs : 23strings . concatStringsSep "\n" ( attrsets . mapAttrsToList renderLine attrs ) 24+ "\n" ; 25 26in { 27options = { 28programs . mangohud = { 29enable = mkEnableOption "Mangohud" ; 30 31package = mkOption { 32type = types . package ; 33default = pkgs . mangohud ; 34defaultText = literalExpression "pkgs.mangohud" ; 35description = "The Mangohud package to install." ; 36}; 37 38enableSessionWide = mkOption { 39type = types . bool ; 40default = false ; 41description = '' 42Sets environment variables so that 43MangoHud is started on any application that supports it. 44'' ; 45}; 46 47settings = mkOption { 48type = with types ; attrsOf settingsType ; 49default = { }; 50example = literalExpression '' 51{ 52output_folder = ~/Documents/mangohud/; 53full = true; 54} 55'' ; 56description = '' 57Configuration written to 58{file}`$XDG_CONFIG_HOME/MangoHud/MangoHud.conf`. See 59<https://github.com/flightlessmango/MangoHud/blob/master/data/MangoHud.conf> 60for the default configuration. 61'' ; 62}; 63 64settingsPerApplication = mkOption { 65type = with types ; attrsOf ( attrsOf settingsType ); 66default = { }; 67example = literalExpression '' 68{ 69mpv = { 70no_display = true; 71} 72} 73'' ; 74description = '' 75Sets MangoHud settings per application. 76Configuration written to 77{file}`$XDG_CONFIG_HOME/MangoHud/{application_name}.conf`. See 78<https://github.com/flightlessmango/MangoHud/blob/master/data/MangoHud.conf> 79for the default configuration. 80'' ; 81}; 82}; 83}; 84 85config = mkIf cfg . enable { 86assertions = [ 87( hm . assertions . assertPlatform "programs.mangohud" pkgs platforms . linux ) 88]; 89 90home . packages = [ cfg . package ]; 91 92home . sessionVariables = mkIf cfg . enableSessionWide { 93MANGOHUD = 1 ; 94MANGOHUD_DLSYM = 1 ; 95}; 96 97xdg . configFile = { 98"MangoHud/MangoHud.conf" = 99mkIf ( cfg . settings != { }) { text = renderSettings cfg . settings ; }; 100} // mapAttrs' 101( n :v :nameValuePair "MangoHud/ ${ n } .conf" { text = renderSettings v ; }) 102cfg . settingsPerApplication ; 103}; 104 105meta . maintainers = with maintainers ; [ zeratax ]; 106}