Skip to content

Commit ac42f22

Browse files
committed
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
1 parent 768acdb commit ac42f22

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Diff for: module-options.nix

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{ config
2+
, options
23
, lib
34
, pkgs
45
, ...
@@ -197,11 +198,14 @@ in
197198
package used to do the formatting.
198199
'';
199200
defaultText = lib.literalMD "Programs used in configuration";
200-
default = pkgs.lib.concatMapAttrs
201-
(
202-
k: v: if v.enable then { "${k}" = v.package; } else { }
203-
)
204-
config.programs;
201+
default =
202+
pkgs.lib.concatMapAttrs
203+
(
204+
k: v:
205+
if options.programs.${k}.enable.visible && v.enable then
206+
{ "${k}" = v.package; } else { }
207+
)
208+
config.programs;
205209
};
206210
check = mkOption {
207211
description = ''

0 commit comments

Comments
 (0)