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-architecture | 53 Servers |
| Sender | Message | Time |
|---|---|---|
| 23 Jul 2022 | ||
| * 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.
| 06:13:41 | |
| * 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 lol | 06:24:13 | |
| 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, 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 | |
| * 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 | |
| * 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 | |
| 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. | 06:48:04 | |
| * 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 | |
| holy hell your employer is paying for all of this? | 14:13:05 | |
| Sorry I just skimmed the text because the IRC bridge really does not like edits and just duplicates the whole message every time | 14:14:01 | |
| My 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/modules | 14:15:31 | |
| In particular, a tool that solves all use-cases is not feasible | 14:15:48 | |
| Plus, 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 company | 14:16:49 | |
| I saw a good quote yesterday āIf you think your code is clever, chances are you are doing something stupidā :P | 14:17:30 | |
| If 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 | |
| I 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 | |
| (plus the tool that has the heuristics for finding license headers etc. is probably more work & value) | 14:20:33 | |
| Thanks 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 | |
| And 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 | |
| With regards to the overrides/overlay question, I've had much more luck with the more limited (though less documented) scope concept. | 19:26:50 | |
| This 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#L184 | 20:14:31 | |
| I'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 | |
| 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. | 20:19:10 | |
| One tricky part is I can't use packages as function args, so the fixed points are actually critical for topology | 20:20:14 | |
| The 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 | |
| Currently the 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 | |
| * Currently the 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 | |
In reply to @growpotkin1:matrix.org I've been iterating on a variant of this, called
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 | |
In reply to @growpotkin1:matrix.org* I've been iterating on a variant of this, called
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 | |
| Now that right there is nifty | 21:44:07 | |
| It seems (to me at least) easier to understand and use, but is strictly less powerful than overlay/overrides. | 21:44:21 | |