Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: only eval enable option if visible #214

Merged
merged 1 commit into from
Aug 10, 2024
Merged

fix: only eval enable option if visible #214

merged 1 commit into from
Aug 10, 2024

Conversation

zimbatm
Copy link
Member

@zimbatm zimbatm commented Aug 10, 2024

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

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
@zimbatm zimbatm force-pushed the fix-trace-warning branch from ac42f22 to 685df3d Compare August 10, 2024 13:15
@zimbatm zimbatm merged commit 5a3a9f9 into main Aug 10, 2024
242 checks passed
@zimbatm zimbatm deleted the fix-trace-warning branch August 10, 2024 13:21
@phanirithvij
Copy link

phanirithvij commented Aug 10, 2024

I've tried it with

nix-info
$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.44, NixOS, 24.11 (Vicuna), 24.11.20240809.5e0ca22`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.5`
 - channels(root): `"nixos"`
 - nixpkgs: `/nix/store/0jr2kk95c34c0b6yxi75q4fqgb43kqkm-source`

logs:

$ nix flake update --commit-lock-file
warning: updating lock file '/shed/Projects/!Own/system/temp/flake.lock':
• Updated input 'treefmt-nix':
    'github:numtide/treefmt-nix/768acdb06968e53aa1ee8de207fd955335c754b7' (2024-07-30)
  → 'github:numtide/treefmt-nix/14c092e0326de759e16b37535161b3cb9770cea3' (2024-08-10)
warning: committed new revision '366f058d046cb30db405bf7a86cf207cdb33fd88'
direnv: loading /shed/Projects/!Own/system/temp/.envrc
direnv: using flake
error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)while evaluating derivation 'nix-shell'
         whose name attribute is located at /nix/store/0jr2kk95c34c0b6yxi75q4fqgb43kqkm-source/pkgs/stdenv/generic/make-derivation.nix:334:7while evaluating attribute 'nativeBuildInputs' of derivation 'nix-shell'

         at /nix/store/0jr2kk95c34c0b6yxi75q4fqgb43kqkm-source/pkgs/stdenv/generic/make-derivation.nix:378:7:

          377|       depsBuildBuild              = elemAt (elemAt dependencies 0) 0;
          378|       nativeBuildInputs           = elemAt (elemAt dependencies 0) 1;
             |       ^
          379|       depsBuildTarget             = elemAt (elemAt dependencies 0) 2;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: attribute 'visible' missing

       at /nix/store/sgfi7jgzrab7hhygl36y29bi3anf4s5b-source/module-options.nix:205:20:

          204|               k: v:
          205|                 if options.programs.${k}.enable.visible && v.enable then
             |                    ^
          206|                   { "${k}" = v.package; } else { }
direnv: nix-direnv: Evaluating current devShell failed. Falling back to previous environment!

In the repo https://github.com/phanirithvij/nix-eval-bugreport

should I open a new issue or can we discuss it here?

zimbatm added a commit that referenced this pull request Aug 10, 2024
Turns out not all options have the visible attribute.
zimbatm added a commit that referenced this pull request Aug 11, 2024
Turns out not all options have the visible attribute.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

remove old deprecation warning for ruff
2 participants