!djTaTBQyWEPRQxrPTb:nixos.org

Nixpkgs Architecture Team

227 Members
https://github.com/nixpkgs-architecture, weekly public meetings on Wednesday 15:00-16:00 UTC at https://meet.jit.si/nixpkgs-architecture53 Servers

Load older messages


SenderMessageTime
23 Jul 2022
@growpotkin1:matrix.orggrowpotkin1 *

I was sent here after seeking the wisdom of "the fixed-point/overlay grey-beards".

I'm 3-4 months down a design rabbit hole and I think it's about time to come talk to the folks who have shot themselves in the foot a few times before I injure myself. I'm not a JS user, honestly don't particularly like web stuff; but work asked me to "make Nix+Node tooling that the an intern could handle - you can open source it, ~6 month timeline". I'm close but I know myself and I've been playing with "fun" fixed points for like 2 weeks and if one of you don't save me from myself... šŸ˜…

I'll just include my original post.

If you are or know who are the wizards who wrote some of the Haskell newScope or related overlays - I would like to formally request counsel with the elders.
I've been working on some open source Nix+Node.js tooling for ~3 months, and I've accomplished quite a bit; but I'm at this stage where I'm going off the deep end with fixes/extends to basically create crawlers for package metadata. It's a blast; but I need to consult with people who have shot their feet a few times with this stuff because it can turn into a real time sink and I'm going to be out of toes soon. Haskell here is just an example because it is abundantly clear that those authors also went - fully off the deep end; but honestly if you've built any of the fixed-points or overlay systems in nixpkgs let me know.
My puzzle for today has basically been "when should I stack up raw overlays, and at which breakpoints in a pipeline do I compose and apply them". I sort arrived at the realization that a break between "gather pure metadata", optionally "gather impure metadata", "generate stage 1", and "get wild with a scoped callPackage style final round" are sensible; but deciding which of those are exposed for users is and experimenting more is getting nasty because I'm so deep down the path on certain patterns. I need a guide.
I went from "keep it simple stupid" a month ago to "absolutely every piece of data needs to be overridable" once I started collecting all of my functions/builders into an API and a part of me sort of knows "I have loaded a large caliber footgun that is going to go off soon" lol.

06:13:41
@growpotkin1:matrix.orggrowpotkin1 * Overall, I'm exaggerating for effect here, I've honestly got a lot done and could crank this out as something "functional" but somewhat inflexible in a day or two. But inflexible ain't gonna cut it - I'm trying to make a tool we can all actually live with! ( "we" as in "us Nix nerds" - because I'm hoping that if the intern understands it, it'll be useful in Nixpkgs ). I'm close, but I have definitely spent two weeks playing with overlays/fixed-points and as education as it has been I need to spend some time in Office Hours to get some direction lol06:24:13
@growpotkin1:matrix.orggrowpotkin1And just to sweeten the pot here: what I have written so far beats both Yarn and NPM on speed and uses less than half of the system resources - with a bare Nix store. With a populated store it's no contest, and I'm obviously an excentric but I think there's a real possibility that if this was flexible Nix could be a legitimate competitor and pick up a chunk of new users. Nix roped me in ~6 years ago by blowing Cabal and Stack out of the water and JS could be an even bigger draw. And just to clear the air a bit : I was upfront about the fact that there's overlap with work/OSS here but I maintain `libtool` for GNU and you can rest assured that I ain't fishing for anybody to consult on this just to turn it over to the company. 06:38:13
@growpotkin1:matrix.orggrowpotkin1* And just to sweeten the pot here: what I have written so far beats both Yarn and NPM on speed and uses less than half of the system resources - with a bare Nix store. With a populated store it's no contest. I'm obviously an excentric but I think there's a real possibility that if this was flexible Nix could be a legitimate competitor and pick up a chunk of new users. Nix roped me in ~6 years ago by blowing Cabal and Stack out of the water and JS could be an even bigger draw. And just to clear the air a bit : I was upfront about the fact that there's overlap with work/OSS here but I maintain `libtool` for GNU and you can rest assured that I ain't fishing for anybody to consult on this just to turn it over to the company. 06:40:05
@growpotkin1:matrix.orggrowpotkin1* And just to sweeten the pot here: what I have written so far beats both Yarn and NPM on speed and uses less than half of the system resources - with a bare Nix store. With a populated store it's no contest. I'm obviously an excentric but I think there's a real possibility that if this was flexible and user ( intern ) friendly, Nix could be a legitimate competitor and pick up a chunk of new users. Nix roped me in ~6 years ago by blowing Cabal and Stack out of the water and JS could be an even bigger draw. And just to clear the air a bit : I was upfront about the fact that there's overlap with work/OSS here but I maintain `libtool` for GNU and you can rest assured that I ain't fishing for anybody to consult on this just to turn it over to the company. 06:40:50
@growpotkin1:matrix.orggrowpotkin1The Nixpkgs' manual for Node.js currently recommends using Nix as a wrapper around NPM/Yarn. I disagreed, and mapped `package.json` and locks directly into derivations - this approach never invokes NPM or Yarn. I spent months reimplementing those tools as pure Nix expressions, and I gated all IFD behind conditionals so it could be used in Nixpkgs. This, converts and optimizes NPM and Yarn projects into Nix projects, and while it's seamless, it leads users to further optimize their build by using Nix directly. 06:48:04
@growpotkin1:matrix.orggrowpotkin1* The Nixpkgs' manual for Node.js currently recommends using Nix as a wrapper around NPM/Yarn. I disagreed, and mapped `package.json` and locks directly into derivations - this approach never invokes NPM or Yarn. I spent months reimplementing those tools as pure Nix expressions, and I gated all IFD behind conditionals so it could be used in Nixpkgs. This, converts and optimizes NPM and Yarn projects into Nix projects, and while it's seamless, it leads users to further optimize their build by using Nix directly. If you want to use it on top on your slower package manager you can; but if you're trying to sell your org on Nix this flow let's you infect during a transition and "flip the switch" to pure Nix when you get the green light. This isn't incidental. It's exactly what I needed to do at my org, and I imagine that it's something most of y'all have schemed over at some point šŸ˜‚06:55:12
@profpatsch:augsburg.oneprofpatschholy hell your employer is paying for all of this?14:13:05
@profpatsch:augsburg.oneprofpatschSorry I just skimmed the text because the IRC bridge really does not like edits and just duplicates the whole message every time14:14:01
@profpatsch:augsburg.oneprofpatschMy unfortunate realization after working with overlays a bunch: It’s not worth the efforts trying to override things in a generalized way, best just focus on the specific task at hand and don’t be afraid to copy & paste some definitions/modules14:15:31
@profpatsch:augsburg.oneprofpatschIn particular, a tool that solves all use-cases is not feasible14:15:48
@profpatsch:augsburg.oneprofpatschPlus, if this is for work, maintainability will trump any kind of cleverness, so if you already hit a dead end after going into the deep end for two weeks, think about the poor soul that will take over the codebase when you inevitably leave the company14:16:49
@profpatsch:augsburg.oneprofpatschI saw a good quote yesterday ā€œIf you think your code is clever, chances are you are doing something stupidā€ :P14:17:30
@profpatsch:augsburg.oneprofpatschIf by ā€œmetadata generationā€ you mean something like ā€œgenerate license compliance documentsā€, that definitely feasible with nixpkgs, but I wouldn’t trust the metadata to be correct. In that case you have to actually unpack the source tarballs and search for the license in there.14:19:08
@profpatsch:augsburg.oneprofpatschI think a good 80/20 solution for that could be possible and would be valuable (even as a product), but no idea whether that’s the use-case.14:19:50
@profpatsch:augsburg.oneprofpatsch(plus the tool that has the heuristics for finding license headers etc. is probably more work & value)14:20:33
@growpotkin1:matrix.orggrowpotkin1Thanks this is what I needed to hear. Yeah what I before the overlays worked fine and was simple, in cases where you do you need to override you basically had to do it statically in specific files; but that's probably easier to grokk. Maintainability is a good point aa well. I know deep down these slick overlays are going to be hard for contributors to keep clean. 17:07:59
@growpotkin1:matrix.orggrowpotkin1And yeah I'll admit I got a sweet gig here haha. Pay is a bit lower than average, but they're cool with me running off to play with Nix for six months without pressing for deliverables 😁17:11:34
@tomberek:matrix.orgtomberekWith regards to the overrides/overlay question, I've had much more luck with the more limited (though less documented) scope concept.19:26:50
@growpotkin1:matrix.orggrowpotkin1This was my take on `makeScope`. What hasn't clicked for me yet is how to nest multiple layers of scopes in a way that isn't painful. This is basically hacked together from `makeExtensible` and `makeScope` sources though : https://github.com/aameen-tulip/at-node-nix/blob/nps-scoped/lib/meta.nix#L18420:14:31
@growpotkin1:matrix.orggrowpotkin1I've also made like 3 attempts at a "recursive merge" that usually winds up "working... I think" but I have never had real confidence in them šŸ˜‚ 20:16:27
@growpotkin1:matrix.orggrowpotkin1Im nesting 4 layers of those scopes for Nixpkgs Node Packages Node Package "outputs" Package Meta The two outer layers are effectively a `callPackage` style scope, while the inner two are fixed points that crawl metadata and form builders. 20:19:10
@growpotkin1:matrix.orggrowpotkin1One tricky part is I can't use packages as function args, so the fixed points are actually critical for topology 20:20:14
@growpotkin1:matrix.orggrowpotkin1The metadata crawling is where things are getting messy because you can collect some of the data from multiple sources. A priority module type thing would be "nice" but I know I'd be over-engineering 20:22:03
@growpotkin1:matrix.orggrowpotkin1

Currently the __add and __update functors are more or less how I'm avoiding the complexity of "composing" overlays or fooling with priorities. It just that I can't be lazy and compose 1-4 different options for how to fetch a field into one object and "let the magic happen" which kind of sucks, but I'm not sure that stacking up and composing overlays is without its own set of frustrations.

That's one thing I was hoping to get guidance on honestly before I spend a couple of days chasing down that rabbit hole.

20:36:38
@growpotkin1:matrix.orggrowpotkin1 *

Currently the __add and __update functors are more or less how I'm avoiding the complexity of "composing" overlays or fooling with priorities. It's just that I can't be lazy and compose 1-4 different options for how to fetch a field into one object and "let the magic happen" which kind of sucks, but I'm not sure that stacking up and composing overlays is without its own set of frustrations.

That's one thing I was hoping to get guidance on honestly before I spend a couple of days chasing down that rabbit hole.

20:41:34
@tomberek:matrix.orgtomberek
In reply to @growpotkin1:matrix.org
Im nesting 4 layers of those scopes for

Nixpkgs
Node Packages
Node Package "outputs"
Package Meta

The two outer layers are effectively a `callPackage` style scope, while the inner two are fixed points that crawl metadata and form builders.

I've been iterating on a variant of this, called using that operates like this:

using pkgs {
          hello-go = ./pkgs/hello-go;
          hello-perl = ./pkgs/hello-perl;
          hello-rust = ./pkgs/hello-rust;
          haskellPackages = {
            hello-haskell-library = ./pkgs/haskellPackages/hello-haskell-library;
          };
          hello-haskell = ./pkgs/hello-haskell;
          python3Packages = using pkgs.python3Packages {
            hello-python-library = ./pkgs/python3Packages/hello-python-library;
          };
          hello-python = ./pkgs/hello-python;

}

where those libraries are available in the packages that need them and everything is automatically callPackage'd correctly. The end result is then only the packages referenced, not all of Nixpkgs, even though it can access it. It's like a recursiveCallPackageWith. The regular structure here also makes it easy to automatically create that entire call automatically by reading directories/files.

21:30:42
@tomberek:matrix.orgtomberek
In reply to @growpotkin1:matrix.org
Im nesting 4 layers of those scopes for

Nixpkgs
Node Packages
Node Package "outputs"
Package Meta

The two outer layers are effectively a `callPackage` style scope, while the inner two are fixed points that crawl metadata and form builders.
*

I've been iterating on a variant of this, called using that operates like this:

using pkgs {
          hello-go = ./pkgs/hello-go;
          hello-perl = ./pkgs/hello-perl;
          hello-rust = ./pkgs/hello-rust;
          haskellPackages = {
            hello-haskell-library = ./pkgs/haskellPackages/hello-haskell-library;
          };
          hello-haskell = ./pkgs/hello-haskell;
          python3Packages = {
            hello-python-library = ./pkgs/python3Packages/hello-python-library;
          };
          hello-python = ./pkgs/hello-python;

}

where those libraries are available in the packages that need them and everything is automatically callPackage'd correctly. The end result is then only the packages referenced, not all of Nixpkgs, even though it can access it. It's like a recursiveCallPackageWith. The regular structure here also makes it easy to automatically create that entire call automatically by reading directories/files.

21:43:20
@growpotkin1:matrix.orggrowpotkin1Now that right there is nifty21:44:07
@tomberek:matrix.orgtomberekIt seems (to me at least) easier to understand and use, but is strictly less powerful than overlay/overrides.21:44:21

Show newer messages


Back to Room ListRoom Version: 9