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 doesn't work #48

Open
IsakFalk opened this issue Sep 27, 2024 · 5 comments
Open

nix flake show doesn't work #48

IsakFalk opened this issue Sep 27, 2024 · 5 comments

Comments

@IsakFalk
Copy link

Running nix flake show github:BirdeeHub/nixCats-nvim gives the following output (showing only the interesting part):

on  main [!] nixCats-nvim ✦ λ nix flake show github:BirdeeHub/nixCats-nvim
github:BirdeeHub/nixCats-nvim/2b455dab0eee7484ce7c956dccda0a7c2111c18b
...
├───packages
error:
       … while evaluating the attribute 'packages'

         at /nix/store/wxpcl6z2xaniz9grcjmpn6pr1iii9psf-source/flake.nix:416:5:

          415|     # and set the default package to the one passed in here.
          416|     packages = utils.mkAllWithDefault defaultPackage;
             |     ^
          417|

       … in the right operand of the update (//) operator

         at /nix/store/wxpcl6z2xaniz9grcjmpn6pr1iii9psf-source/nix/utils/default.nix:135:28:

          134|     mkAllWithDefault = package:
          135|     { default = package; } // (utils.mkAllPackages package);
             |                            ^
          136|

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

       error: getting status of '/nix/store/fnh35w1nk2jxqsv9j9g6cg44f8q5i2v2-source/pkgs/os-specific/darwin/apple-source-releases/xnu/headers-10.12-arm64.txt': No such file or directory

There seem to be an issue with the way that the arm64 system is looking for header files according to the path.

@BirdeeHub
Copy link
Owner

BirdeeHub commented Sep 28, 2024

Hmmmm nix flake show doesnt like overriding....

How odd. The package builds, but nix flake show cant figure it out.

nix repl is fine with it, nix shell is fine with it, every other nix command doesnt seem to care...

Currently Im not sure I have an easy fix, maybe there is one, I will look at it when I get more time, but there is a workaround if it bothers you and you would rather use that as opposed to the repl. TBH I didnt notice because I always use the repl instead.


So, heres what that function does.

It takes your package. And then it does yourvim.override { name = "adifferentname" }; for all of your packages. Which doesn't just change the name, it selects the package. In this manner, it creates an output for all the packages.

Instead of that, you can simply take the nixCatsBuilder function you make in the outputs that takes a name from package definitions and builds it, and construct the outputs yourself without using override.

I just tested, nix flake show works if you construct the package outputs manually using the builder function, and it works for all the other attributes already

The helper function to make all the ones from package definitions from just the package is nice and stuff, but you have access to a function that takes a name and returns a package, and you can use it all you want.


Hopefully I can get time to come up with a better reply and/or fix it properly somehow very soon. I've been unexpectedly busy the last couple weeks

But for now, if it matters to you, there is a workaround, otherwise, you can use nix repl to see the packages.

@BirdeeHub
Copy link
Owner

BirdeeHub commented Sep 28, 2024

Hmmm

it seems like if I create the outputs set for the packages via a function AT ALL it doesnt like it... Even if I use the old version that doesnt use override...

Why is it ok with overlays set being created via a function then?!


Wait... hang on....

The packages are inside flake-utils...

the devShell is too but thats ok cause thats just a single item

But then I think nix flake show starts to get a bit confused when its already gone through the flake-utils blender and then has to process uhhhh this after that XD

    mkAllPackages = package: let
      allnames = builtins.attrNames package.passthru.packageDefinitions;
    in
    listToAttrs (map (name:
      lib.nameValuePair name (package.override { inherit name; })
    ) allnames);

    mkAllWithDefault = package:
    { default = package; } // (utils.mkAllPackages package);

I think we are basically just hitting the edges of nix flake shows ability to parse it...

Because it DEFINITELY builds and the repl has no problem with it. Its failing to show even the x86_64-linux package outputs, and I use the one from my config daily, it definitely builds, and it builds for the config in the nixCats repo as well.

The only immediate fix that is coming to my mind right now would be to literally just change the templates and recommend people make the set manually as described in my previous reply... And thats kinda lame, its a nice function.

This may be a thing for some time to come, as I am not yet familiar enough with C++ to effectively go about spelunking in the nix flake show code, find the differences, and then posit a reason why nix build can parse it but nix flake show cannot...

For now, I would suggest using the repl to view the outputs (nix repl and then :lf . and then use the autocomplete to look around), or constructing the set of output packages manually rather than using the helper function, or maybe swapping from flake-utils to genAttrs or something

To be fair, even if I remove the nixCats outputs from my personal system flake, it turns out nix flake show still fails me on that too, due to flake-parts with custom flake-parts modules...

It seems nix flake show is a touchy command...

nix repl works every time. It doesnt show the descriptions from the templates, but thats right there in the installation docs anyway, and beyond that you dont really get any extra information from nix flake show comparatively.

@BirdeeHub
Copy link
Owner

The title of this issue is actually EXTREMELY fitting by the way.

I could have literally answered it with "correct, it does not" hahaha

@BirdeeHub
Copy link
Owner

so, now this applies to the example config rather than the main flake

but it still is a thing.

@BirdeeHub
Copy link
Owner

BirdeeHub commented Nov 16, 2024

I know why it is occurring. I dont know why it presented itself in some situations and not in others though. Maybe they tried to ignore such errors and missed somewhere? If it consistently failed in all cases where an output technically isnt supported by a contained package I would say its my fault, but it doesnt, it only fails if you get too complicated. It now makes sense why it only throws for package type outputs. But not why it only SOMETIMES throws for package type outputs of you get too complicated

If instead of nixpkgs.lib.platforms.all you specify the list of platforms nvim supports, it doesnt throw.

I dont really want to change that, as this is general, short, and simple, and users may decide to override the list of platforms nvim officially supports on nix. Hopefully they can finish ignoring such errors in the future in nix flake show.

For now, if it bothers you, change nixpkgs.lib.platforms.all for [ "x86_64-linux" "x86_ ... ] with the 4 default systems.

Leaving the issue open until it doesnt happen so that others know.

So, yeah. 2 workarounds. 1, use repl instead, 2, fix systems list. Up to you.

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

No branches or pull requests

2 participants