5 ms·
I tried to like nix. I spent many hours tweaking my macOS setup but now I’m back to brew. The nix language is just too foreign to my way of thinking. I love the
by johnnylambada 5y ago
I tried to like nix. I spent many hours tweaking my macOS setup but now I’m back to brew. The nix language is just too foreign to my way of thinking. I love the concept behind it but the language is a huge barrier to entry to many people and I believe it will not gain nearly as much traction as it deserves until this is addressed.
- domenkozar 5y agoCould you say more what's foreign?
- johnnylambada 5y agoIts probably that I grew up with c like languages. When I try to read something like { pkgs }: { deps = [ pkgs.cowsay ]; } It’s meaningless to my brain.
- wereHamster 5y agoTranslating to modern JavaScript in three easy steps: { pkgs }: { deps = [ pkgs.cowsay ]; } ({ pkgs }): { deps = [ pkgs.cowsay ]; } ({ pkgs }) => { deps = [ pkgs.cowsay ]; } ({ pkgs }) => ({ deps = [ pkgs.cowsay ]; })
- johnnylambada 5y agoHelpful. There once was a command line tool that would turn a C declaration into english (like cdecl.org) I’d love to see something like that for the nix language (and kotlin too since I’m dreaming)
- TheDong 5y agoYour translation is incomplete. You're ending with: > ({ pkgs }) => ({ deps = [ pkgs.cowsay ]; }) But the syntax for declaring objects in javascript differs. It would be: ({ pkgs }) => ({ deps: pkgs.cowsay }) The fact that '{ x = 1; }' is declaring an object, identical to '{x: 1}' in javascript, is important. It's also worth pointing out that, while '{ pkgs }:' is idiomatic nix, idiomatically in javascript you'd probably just take multiple arguments (so '(pkgs) =>', not '({ pkgs }) =>' in js). The reason nix uses an object there is because a nix function only takes one argument, so there's a fairly common convention to make that argument an attr in order to simulate multiple arguments. That convention doesn't exist in quite the same way in js.
- ronenlh 5y agoYou forgot the array ({ pkgs }) => ({ deps: [pkgs.cowsay] }) I also translate all nix to JavaScript in my brain
- bspammer 5y agoTo put it in a C context: it’s a function with a single argument ‘pkgs’, which returns a struct with one field ‘deps’, which is an array of package structs.
- IshKebab 5y agoSo why did they chose such unconventional syntax? Just for the hell of it? There doesn't seem to be any advantage and it definitely puts a lot of people off.
- bspammer 5y agoThe syntax is not so unconventional compared to, say, modern javascript: ({ pkgs }) => { deps: [ pkgs.cowsay ] } or python: lambda pkgs: { deps: [pkgs.cowsay] } I guess really the question is why create a new language rather than using an existing one? The language needed to be functional, lazy, and good at managing packages, and not much else. I guess they felt that no existing language fits the bill (Haskell does I guess but it's got a lot of baggage). I can't claim to know much about its history.
- month13 5y agoYeah, it’s not as nice as macOS. There’s a ton of magic happening too, so I found it easy to get lost and not fully understand what was happening. I had tried to compile some software that linked against macOS SDKs, and did not realise that Nix essentially maintains it’s own version, and it was quite tricky to adapt to it or get back to using Xcode’s toolchain.
- amasad 5y agoWe’re trying to make it more accessible. Making a GUI or a no code interface is also on the table. But nonetheless we are seeing kids build nix environments. See this hashtag: https://replit.com/apps/nix https://replit.com/apps/nix
- MaxGabriel 5y agoAre there any good initiatives you think companies should fund to improve the accessibility?
- amasad 5y agoI think donating to the Nix foundation would be as good as any.
- rgoulter 5y agoI'm currently using NixOS. I jumped in some time after using Nix with macOS. I think following simple examples is straightforward. I think anyone who can install python and ruby with brew would be able to look at a replit.nix which uses python, and figure out how to change it to also install ruby. Even for just simple cases, I think Nix is compelling and worth looking into. "Nix is weird" becomes more of an issue for a long tail of edge cases, where a developer is likely to bump into one of these, and it won't be clear where in the documentation to go. -- With Nix being so weird, it both requires a familiarity with what you're doing in a standard-linux way, as well as familiarity with how things need to be done with Nix. e.g. the nginxModified in the OP makes use of overrideAttrs. (You'd need to know both that nginx can be configured like that, as well as how to configure with nix).