From 685df3dce0a355120067431acdbcdc7529e61db9 Mon Sep 17 00:00:00 2001 From: zimbatm Date: Sat, 10 Aug 2024 14:00:24 +0200 Subject: [PATCH] fix: only eval enable option if visible When using `lib.mkRenamedOptionModule`, the trace warning is emitted whenever the option is accessed. Because we iterate and check the .enable option of all the programs, the renamed option gets accessed all the time. So we check if the option is "visible" before checking in, which `lib.mkRenamedOptionModule` sets to false. Fixes #211 --- module-options.nix | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/module-options.nix b/module-options.nix index 9d2a208..129329d 100644 --- a/module-options.nix +++ b/module-options.nix @@ -1,4 +1,5 @@ { config +, options , lib , pkgs , ... @@ -197,11 +198,14 @@ in package used to do the formatting. ''; defaultText = lib.literalMD "Programs used in configuration"; - default = pkgs.lib.concatMapAttrs - ( - k: v: if v.enable then { "${k}" = v.package; } else { } - ) - config.programs; + default = + pkgs.lib.concatMapAttrs + ( + k: v: + if options.programs.${k}.enable.visible && v.enable then + { "${k}" = v.package; } else { } + ) + config.programs; }; check = mkOption { description = ''