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

nix flake show: Ignore empty attrsets #7726

Merged
merged 1 commit into from
Feb 1, 2023

Conversation

roberth
Copy link
Member

@roberth roberth commented Jan 31, 2023

Motivation

For frameworks it's important that structures are as lazy as possible to prevent infinite recursions, performance issues and errors that aren't related to the thing to evaluate. filterAttrs makes the set of keys depend on the values. As a consequence, this function can't be used and the framework has to emit more attributes than desirable. However, these attributes with empty values are not useful to the user so we don't add them to the output.

Context

Closes #7285

Solves the need for these issues that I can't resolve without causing infinite recursions when people use self.

Checklist for maintainers

Maintainers: tick if completed or explain if not relevant

  • agreed on idea
  • agreed on implementation strategy
  • tests, as appropriate
    • functional tests - tests/**.sh
    • unit tests - src/*/tests
    • integration tests - tests/nixos/*
  • documentation in the manual
  • code and comments are self-explanatory
  • commit message explains why the change was made
  • new feature or bug fix: updated release notes

For frameworks it's important that structures are as lazy as possible
to prevent infinite recursions, performance issues and errors that
aren't related to the thing to evaluate. As a consequence, they have
to emit more attributes than strictly (sic) necessary.
However, these attributes with empty values are not useful to the user
so we omit them.
@edolstra edolstra merged commit 845b7f0 into NixOS:master Feb 1, 2023
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nix-2-14-0-released/25900/2

@oxalica
Copy link
Contributor

oxalica commented Mar 26, 2023

Just bisected here. This breaks the output for nixpkgs. legacyPackages are no longer traversed even with --legacy.

$ nix flake show github:NixOS/nixpkgs/nixos-unstable --legacy
github:NixOS/nixpkgs/8f40f2f90b9c9032d1b824442cfbbe0dbabd0dbd
├───checks
│   └───x86_64-linux
│       └───tarball: derivation 'nixpkgs-tarball-23.05pre20230325.8f40f2f'
├───htmlDocs: unknown
├───legacyPackages
├───lib: unknown
└───nixosModules
    └───notDetected: NixOS module

@oxalica oxalica mentioned this pull request Mar 26, 2023
7 tasks
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.

nix flake show shows empty attrsets
4 participants