From 6de4ec780ebcb775a88535181f0928249224fb83 Mon Sep 17 00:00:00 2001 From: Cecilia Sanare Date: Fri, 22 Mar 2024 13:48:54 -0500 Subject: [PATCH] fix(nix): simplify protontweaks config setup --- nix/home-manager.nix | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/nix/home-manager.nix b/nix/home-manager.nix index 19e48b9..266c17f 100644 --- a/nix/home-manager.nix +++ b/nix/home-manager.nix @@ -2,25 +2,29 @@ let cfg = config.services.protontweaks; - inherit (lib) mkIf mkEnableOption; -in -{ - options.services.protontweaks = { - enable = mkEnableOption "protontweaks"; + inherit (lib) mkIf mkEnableOption mkOption types; + inherit (types) nullOr; - gamemode = mkEnableOption "automatic gamemode initialization" // { - default = true; - }; + protontweaksConfig = with types; submodule + { + options = { + gamemode = mkEnableOption "automatic gamemode initialization" // { + default = true; + }; - mangohud = mkEnableOption "automatic mangohud initialization" // { - default = false; + mangohud = mkEnableOption "automatic mangohud initialization" // { + default = false; + }; + }; }; +in +{ + options.services.protontweaks.config = mkOption { + description = "The protontweaks config"; + type = nullOr (protontweaksConfig); }; - config = mkIf (cfg.enable) { - home.file.".config/protontweaks.json".text = builtins.toJSON ({ - gamemode = cfg.gamemode; - mangohud = cfg.mangohud; - }); + config = mkIf (cfg.config != null) { + home.file.".config/protontweaks.json".text = builtins.toJSON cfg.config; }; }