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 should be filterable by the current system #6985

Closed
NobbZ opened this issue Sep 1, 2022 · 4 comments · Fixed by #6988
Closed

nix flake show should be filterable by the current system #6985

NobbZ opened this issue Sep 1, 2022 · 4 comments · Fixed by #6988
Labels
feature Feature request or proposal flakes new-cli Relating to the "nix" command UX The way in which users interact with Nix. Higher level than UI.

Comments

@NobbZ
Copy link
Contributor

NobbZ commented Sep 1, 2022

Is your feature request related to a problem? Please describe.

Often when one runs nix flake show nix tries to evaluate every well known output, though some of them depend on the system, and even worse, some of them use IFD, so to nix being able to show the information it needs to build for a foreign system.

This leads to errors like this:

$ nix flake show github:nix-community/nix-doom-emacs
github:nix-community/nix-doom-emacs/ae22b4a3fe31ae31b3e8b415889f8c2c5a77d8dc
├───checks
│   ├───aarch64-darwin
error: a 'aarch64-darwin' with features {} is required to build '/nix/store/a5dhhm5nhn936q5177nlv3fn3b4jvqly-source.drv', but I am a 'x86_64-linux' with features {benchmark, big-parallel, kvm, nixos-test}
(use '--show-trace' to show detailed location information)

Describe the solution you'd like

nix flake show becomes system aware and does not try to evaluate foreign systems, but instead just shows an ellipsis as child for foreign systems. A fictive example could look like this:

$ nix flake show github:nobbz/nixos-config
github:nobbz/nixos-config/e460e5272935ea1e902c04e9c705e8dc938d6383
└───checks
    ├───aarch64-darwin
    │   └───... omitted (use '--foreign-systems' to show)
    └───x86_64-linux
        ├───alejandra: derivation 'alejandra-run-e460e5272935ea1e902c04e9c705e8dc938d6383'
        └───statix: derivation 'statix-run-e460e5272935ea1e902c04e9c705e8dc938d6383'

An extra flag could be introduced to "try anway" similar to how we use --legacy to get the full list of packages in legacyPackages, perhaps --foreign-systems as in the example above.

Describe alternatives you've considered

Fully forbid any kind of IFD in flake contexts.

Additional context

Actually I would totally prefer the alternative, though I see that the community isn't there yet and instead we need to raise awareness about the issue.

@Kha
Copy link
Contributor

Kha commented Sep 1, 2022

Actually I would totally prefer the alternative, though I see that the community isn't there yet and instead we need to raise awareness about the issue.

I think your suggestion is the correct UX default irrespective of IFD. For any nontrivial flake with a nontrivial amount of supported systems, the output way is just way too redundant to answer simple questions about platform support like a) what is the total set of derivations available on any platform, and b) what platforms does this derivation support. If those are use cases flake show wants to support, I think it would have to learn to deduplicate the output as in e.g.

└───checks
    └───aarch64-darwin, x86_64-linux, ...
        ├───alejandra: derivation 'alejandra-run-e460e5272935ea1e902c04e9c705e8dc938d6383'  # assuming that hash is not platform-dependent
        └───statix: derivation 'statix-run-e460e5272935ea1e902c04e9c705e8dc938d6383'

@peterbecich
Copy link
Contributor

Is this still an issue?

% nix --version
nix (Nix) 2.14.1


% nix flake show                      
...
error: a 'aarch64-darwin' with features {} is required to build 
'/nix/store/2gir7h9fgl7rkdxfs1nc2q84s9szxbgx-cabal2nix-example.drv', 
but I am a 'x86_64-linux' with features {benchmark, big-parallel, kvm, nixos-test, uid-range}

#6988 notes that the fix does not apply to Hydra jobs. Is this cabal2nix-example a Hydra job? Thanks

@peterbecich
Copy link
Contributor

Also with Nix 2.15:

%  nix --version
nix (Nix) 2.15.0


% nix flake show

error:
....
features {} is required to build 
'/nix/store/2gir7h9fgl7rkdxfs1nc2q84s9szxbgx-cabal2nix-example.drv', 
but I am a 'x86_64-linux' with features {benchmark, big-parallel, kvm, nixos-test, uid-range}

@peterbecich
Copy link
Contributor

The prior error must have been because the build was a Hydra job.

In this example show works correctly:

└───packages
    ├───aarch64-darwin
    │   ├───default omitted (use '--all-systems' to show)
    │   └───main-hackage-server omitted (use '--all-systems' to show)
    ├───x86_64-darwin
    │   ├───default omitted (use '--all-systems' to show)
    │   └───main-hackage-server omitted (use '--all-systems' to show)
    └───x86_64-linux
        ├───default: package 'hackage-server-0.5.1'
        └───main-hackage-server: package 'hackage-server-0.5.1'

https://github.com/haskell/hackage-server/blob/master/flake.nix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request or proposal flakes new-cli Relating to the "nix" command UX The way in which users interact with Nix. Higher level than UI.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants