1

implement initial gaming module

This commit is contained in:
2022-08-08 23:34:28 +02:00
parent 8028d9d7ed
commit 7886588ad7

View File

@ -5,11 +5,79 @@ with mylib.modules;
let
cfg = config.modules.gaming;
flatpak = config.modules.flatpak;
cfgfp = config.modules.flatpak;
in {
imports = [ ];
imports = [
# NOTE: I don't know if this is the right approach or if I should use config.modules.flatpak
./flatpak.nix
];
options.modules.gaming = {};
options.modules.gaming = {
enable = mkBoolOpt false "Enable the Gaming module";
discordChromium.enable = mkBoolOpt false "Enable Discord as Chromium webapp";
polymc.enable = mkBoolOpt false "Enable PolyMC for Minecraft (flatpak)";
# TODO: Add specific gaming bottles configs?
bottles.enable = mkBoolOpt false "Enable Bottles to emulate Windows games (flatpak)";
config = mkIf cfg.enable {};
noisetorch = {
enable = mkBoolOpt false "Enable Noisetorch";
autostart = mkBoolOpt false "Autostart Noistorch";
};
steam = {
enable = mkBoolOpt false "Enable steam (flatpak)";
protonGE = mkBoolOpt false "Enable Steam Proton GloriousEggroll runner (flatpak)";
gamescope = mkBoolOpt false "Enable the gamescope micro compositor (flatpak)";
};
};
config = mkIf cfg.enable {
assertions = [
(mkIf cfg.steam.enable {
assertion = cfgfp.enable;
message = "Cannot enable Steam without the flatpak module!";
})
(mkIf cfg.polymc.enable {
assertion = cfgfp.enable;
message = "Cannot enable PolyMC without the flatpak module!";
})
(mkIf cfg.bottles.enable {
assertion = cfgfp.enable;
message = "Cannot enable Bottles without the flatpak module!";
})
];
home.packages = with pkgs; builtins.concatLists [
[ gamemode ] # gamemode should be always enabled (could also be enabled by audio module)
# TODO: Extra config (extensions etc), maybe standalone chromium module
(optionals cfg.discordChromium.enable [ chromium ])
];
xdg.desktopEntries.discordChromium = mkIf cfg.discordChromium.enable {
name = "Discord (Chromium)";
genericName = "Online voice chat";
icon = "discord";
exec = "chromium --new-window discord.com/app";
terminal = false;
categories = [ "Network" "Chat" ];
};
# NOTE: Important to not disable this option if another module enables it
modules.flatpak.bottles.enable = mkIf cfg.bottles.enable true;
modules.flatpak.extraInstall = builtins.concatLists [
(optionals cfg.steam.enable [ "com.valvesoftware.Steam" ])
(optionals (cfg.steam.enable && cfg.steam.protonGE) [ "com.valvesoftware.Steam.CompatibilityTool.Proton-GE" ])
(optionals (cfg.steam.enable && cfg.steam.gamescope) [ "com.valvesoftware.Steam.Utility.gamescope" ])
(optionals cfg.polymc.enable [ "org.polymc.PolyMC" ])
];
modules.flatpak.extraRemove = builtins.concatLists [
(optionals (!cfg.steam.enable) [ "com.valvesoftware.Steam" ])
(optionals (!cfg.steam.enable || !cfg.steam.protonGE) [ "com.valvesoftware.Steam.CompatibilityTool.Proton-GE" ])
(optionals (!cfg.steam.enable || !cfg.steam.gamescope) [ "com.valvesoftware.Steam.Utility.gamescope" ])
(optionals (!cfg.polymc.enable) [ "org.polymc.PolyMC" ])
];
};
}