From 138d1bd1b3cf8835a5f00b926f30023fcf91471f Mon Sep 17 00:00:00 2001 From: worble Date: Sat, 8 Feb 2025 13:26:08 +0000 Subject: [PATCH] use mkIf for conditionals --- home-manager/terminal.nix | 47 +++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/home-manager/terminal.nix b/home-manager/terminal.nix index f442a3a..066e191 100644 --- a/home-manager/terminal.nix +++ b/home-manager/terminal.nix @@ -4,13 +4,16 @@ with lib; { options.terminal = { nixUpdateLocation = mkOption { - type = types.str; + type = lib.types.nullOr lib.types.str; + default = null; }; flakeUpdateLocation = mkOption { - type = types.str; + type = lib.types.nullOr lib.types.str; + default = null; }; homeUpdateLocation = mkOption { - type = types.str; + type = lib.types.nullOr lib.types.str; + default = null; }; }; @@ -139,18 +142,38 @@ with lib; topgrade = with config.terminal;{ enable = true; - settings = { + # settings = { + # misc = { + # assume_yes = true; + # }; + # linux = { + # nix_arguments = if nixUpdateLocation != null then "--flake ${nixUpdateLocation}" else default; + # home_manager_arguments = if homeUpdateLocation != null then "--flake ${homeUpdateLocation}" else ""; + # }; + # pre_commands = { + # nix-flake-update = if flakeUpdateLocation != null then "sudo nix flake update --flake ${flakeUpdateLocation}" else ""; + # }; + # }; + settings = mkMerge [{ misc = { assume_yes = true; }; - linux = { - nix_arguments = if nixUpdateLocation then "--flake ${nixUpdateLocation}" else null; - home_manager_arguments = if homeUpdateLocation then "--flake ${homeUpdateLocation}" else null; - }; - pre_commands = { - nix-flake-update = if flakeUpdateLocation then "sudo nix flake update --flake ${flakeUpdateLocation}" else null; - }; - }; + } + (mkIf (nixUpdateLocation != null) { + linux = { + nix_arguments = "--flake ${nixUpdateLocation}"; + }; + }) + (mkIf (homeUpdateLocation != null) { + linux = { + home_manager_arguments = "--flake ${homeUpdateLocation}"; + }; + }) + (mkIf (flakeUpdateLocation != null) { + pre_commands = { + nix-flake-update = "sudo nix flake update --flake ${flakeUpdateLocation}"; + }; + })]; }; alacritty = {