Skip to content

Commit

Permalink
fix: only eval enable option if visible
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zimbatm committed Aug 10, 2024
1 parent 768acdb commit 685df3d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions module-options.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ config
, options
, lib
, pkgs
, ...
Expand Down Expand Up @@ -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 = ''
Expand Down

0 comments on commit 685df3d

Please sign in to comment.