How to climb up the learning curve? (specifically nixpkgs/haskellPackages)

I have been using Nix for a couple of years now, I am in no way a beginner, but I can not say I am an intermediate user either.

Recently I had the experience of getting Haskell static executable building to work (not for the first time, but things changed since I last did it), which sits on the shoulder of giants, @nh2 ‘s work, and nixpkgs’ Haskell infrastructure.
I am infinitely grateful to their work, at the same time I am pretty frustrated that I had to spend a couple of days guessing and guessing and guessing magic incantations until I got everything to finally work. This is in no way a complaint, nor is it a problem with nix/nixpkgs, it is simply due to my incompetence and I would like to fix it, hence this post.

I would have gladly spent this time problem-solving my way into a successful build IF I could at least understand or know what I should read (code as well) in order to understand what is going on.
Every time I try to learn what is going on in nixpkgs I go completely lost in the sheer complexity of it and give up, just guessing the appropriate fix. When nix builds fail it could be at any level of abstraction how do I got about familiarising myself with all those layers so that I can troubleshoot intelligently?
I am lurking on this forum and there are enough users (at the double digits) that show that they have an understanding of how things work together or when there is a problem, what is a possible culprit, how to advance etc.

I would also want to be in this position, I understand that the road is going to be long. I want to use Nix
but troubleshooting by way of guessing is depressing. For those of you who know their way or that at least manage to browse nixpkgs and grok this complexity, or that at least manage to understand it partially as it is needed by reading only the relevant parts to the problem at hand, how did you get to this position? What should I learn? How should I practice? Perhaps just giving me an order in which to read .nix files out of nixpkgs is all that is needed, perhaps that is just the beginning. I admit I am not an expert when it comes to building stuff in general in Linux, and perhaps that is a necessity to use nixpkgs proficiently. If that is the case, I would be grateful if you could just point me to the tomes I should read.
I already devour each and every blog post (or otherwise manuals) on the internet about nix and nixpkgs like a thirsty wanderer in the desert.
When builds break and I have no idea why, how to begin trying to troubleshoot intelligently?

e.g. when I am getting

crtbeginT.o: requires dynamic R_X86_64_32 reloc against '__TMC_END__' which may overflow at runtime; recompile with -fPIC

how do some of you approach this in order to understand where the problem is coming from?
I am not fixated on this example so feel free to share others instead, whatever you can.

Sorry for making such a scattered and ambivalent post, I just don’t want to narrow down the responses I receive. I will appreciate whatever you have to say that relates to anything I said.

All responses to this thread and to other threads on this discourse are (were always) appreciated! Thank you!

7 Likes

Just want to point out that many of us know one or more parts in detail, but then not much about the rest of Nixpkgs. Nixpkgs is huge, and it requires significant effort to learn about the various parts.

Thus, all I can advice here is to pick a part of interest (Haskell packages I suppose) and go deep into it, solve existing issues, open and review PR’s related to it and do this for a while. I think that’s the only way to truly get to the level of competence you are describing. In my experience the IRC channels were very useful in getting input on how to debug certain issues, as was the feedback on specific questions on the issue tracker.

Not being familiar with this error I first put in Google hoping to find something human readable explaining what it is about and how it may be resolved. Now, the error says it has something to do with the compile flags, and I guess from previous experience it might be because we do something too strict so that it may be related to hardening flags but that’s just a guess.

Anyway, depending on the web search search I use GitHub to search in our repo as well (and if I am aware of any other repo’s those as well). Then, I use git log --grep and git grep because its not unlikely somebody encountered it before. After that I would go to the #nixpkgs IRC channel and drop the question there. Often people have ideas.

Assuming we get to an answer there, then I would say we can be happy about it. While you would not have solved it entirely by yourself, you’ve used the knowledge from your peers and made the knowledge spread which is a great thing. Best to record it somewhere in an issue or commit message. Also, having dropped the question on the IRC channel it will often be that if the question is asked later again, someone recalls that and can refer that person.

3 Likes

Thanks for your helpful reply.

I guess that will have to be the way to go then.

I will try to follow these steps next time I stumble upon an error I can not understand.

Thanks!

Nix is big. I’m a total newbie after a year but here has been what helped me

  1. accept that nix curve is steeped than vim, yet unlike vim which is reinforcing, nix makes you. Forget things , because, well, you write something only once. I solve this problem by not installing programming language stuff globally. If you’re doing something new, spend five minutes to write a .nix file.

  2. master the very basics of language, and then understand the tools gradually with intuition. There are multiple ways of doing things. I just use nixos-rebuild and Nix- shell. It’s better to be expert at one tool than know flags of all

  3. not nixpkgs related, but NixOS related- what helps a lot (if you have prior linux experience) is to browse arch or Gentoo wiki for a topic first, understand it in a framework you are already familiar with and then understand it in nix way.

2 Likes

Thank you for your reply, fellow climber!

Hopefully we both will make great progress from here on out.

My major issue with nix, is that generally the user experience isn’t great the first time I attempt something. Generally I have to do some hacking, and know nix + technology to make it work as I need.

However, once you overcome that, you do get a lot of benefit from being able to do things the “nix-way” (idempotent builds, isolated environments, etc)