From 2a4fd1cfd8ed5648583dadef86966a8231024221 Mon Sep 17 00:00:00 2001 From: Sergey Date: Tue, 8 Oct 2024 22:34:31 +0100 Subject: [PATCH] eza: fix icons option Fixes the icons option for eza which was breaking completion in zsh. --- docs/release-notes/rl-2411.md | 5 +++++ modules/programs/eza.nix | 24 ++++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/docs/release-notes/rl-2411.md b/docs/release-notes/rl-2411.md index 6f7a6b7b..62662464 100644 --- a/docs/release-notes/rl-2411.md +++ b/docs/release-notes/rl-2411.md @@ -18,6 +18,11 @@ This release has the following notable changes: add `-w` to your assignment of [services.swayidle.extraArgs](#opt-services.swayidle.extraArgs). +- Support for Boolean values in the option + [programs.eza.icons](#opt-programs.eza.icons) is deprecated for + future removal. The new value for `true` is `"auto"`, and for + `false` it is `null`. + ## State Version Changes {#sec-release-24.11-state-version-changes} The state version in this release includes the changes below. These diff --git a/modules/programs/eza.nix b/modules/programs/eza.nix index d55d6f56..679f5349 100644 --- a/modules/programs/eza.nix +++ b/modules/programs/eza.nix @@ -49,10 +49,13 @@ with lib; }; icons = mkOption { - type = types.bool; - default = false; + type = types.enum [ null true false "auto" "always" "never" ]; + default = null; description = '' Display icons next to file names ({option}`--icons` argument). + + Note, the support for Boolean values is deprecated. + Setting this option to `true` corresponds to `--icons=auto`. ''; }; @@ -70,8 +73,15 @@ with lib; config = let cfg = config.programs.eza; - args = escapeShellArgs (optional cfg.icons "--icons" - ++ optional cfg.git "--git" ++ cfg.extraOptions); + iconsOption = let + v = if isBool cfg.icons then + (if cfg.icons then "auto" else null) + else + cfg.icons; + in optionals (v != null) [ "--icons" v ]; + + args = escapeShellArgs + (iconsOption ++ optional cfg.git "--git" ++ cfg.extraOptions); optionsAlias = optionalAttrs (args != "") { eza = "eza ${args}"; }; @@ -83,6 +93,12 @@ with lib; lla = "eza -la"; }; in mkIf cfg.enable { + warnings = optional (isBool cfg.icons) '' + Setting programs.eza.icons to a Boolean is deprecated. + Please update your configuration so that + + programs.eza.icons = ${if cfg.icons then ''"auto"'' else "null"}''; + home.packages = [ cfg.package ]; programs.bash.shellAliases = optionsAlias