use mkIf for conditionals

This commit is contained in:
2025-02-08 13:26:08 +00:00
parent 6d0f9224be
commit 138d1bd1b3

View File

@@ -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 = {