Re:Flakes – Proposed mechanism to package Nix expressions in...
by jforberg on Saturday July 20, 2019 @06:52PM
(#20488830)
I mostly deal with openembedded at work and I have few positive things to say about it. I'm sure Nix is much faster and nicer. Frankly it's hard to imagine that the opposite could be true.
But your example looks nothing like Json.
Re:Flakes – Proposed mechanism to package Nix expressions in...
by vertex-four on Saturday July 20, 2019 @06:59PM
(#20488856)
I'm not sure what to say. Replace the = signs with colons, the semicolons with commas, stick commas between array elements and stick everything between quotes and you basically have json.
Re:Flakes – Proposed mechanism to package Nix expressions in...
by weberc2 on Sunday July 21, 2019 @08:24AM
(#20491038)
The complicated bits are the import notations (what do the different variations mean and when to use them?), the recursive declarations (and knowing when to use them). Also, since expressions are often functions and the nixpkgs people don’t believe in types or docs, it’s difficult to track down the type info for each argument (what properties does it have?). You just end up grepping blindly through nixpkgs to find the callsite and even then the argument is often the result of a function call, so you have to find the function and it’s definition and look at the return and hope that it is not “return someOtherFunc()” lest you have to track down yet another function (also, odds are “someOtherFunc” is not the name of the function, but rather the name of a parameter into which a function was passed, so you’re back to blindly grepping nixpkgs).
Nix is great in concept but the language or idioms make it really difficult to use.
Re:Flakes – Proposed mechanism to package Nix expressions in...
by tannhaeuser on Sunday July 21, 2019 @02:42AM
(#20490249)
That looks like a Turing-complete DSL. Not like JSON at all. Do we need yet another Turing-complete language for writing package metadata?
Re:Flakes – Proposed mechanism to package Nix expressions in...
by viraptor on Sunday July 21, 2019 @03:19AM
(#20490326)
The example lacks functions / flow-control statements (ok, apart from "import if not defined", but it's more of a default value than a branch) / references to other elements. It's pretty much key-value dictionary. Not sure how you got an impression of Turing-complete DSL from that, since it would require at least one of them.
Re:Flakes – Proposed mechanism to package Nix expressions in...
by weberc2 on Sunday July 21, 2019 @08:26AM
(#20491043)
The Nix expression language has branches and functions (including recursive functions). It is Turing complete, and it probably is necessary for its charter.
Re:Flakes – Proposed mechanism to package Nix expressions in...
by viraptor on Sunday July 21, 2019 @05:36PM
(#20493824)
OP said it "looks like" a Turing complete DSL just from the example. Regardless of what extra functionality the actually is, the examples didn't suggest it.
From there, the first line in the original example says "the following expression is a function that is called with this parameter", and the parameter is an object containing a key called "pkgs", which is defaulted to the result of "import <nixpkgs> {}". This is explained in more detail in a handful of lines in the language manual.
Functions are called just by referencing the function and then the arguments separated with spaces, like Ruby or Haskell - so python3Packages.buildPythonApplication is a function that is called with the object above.
Finally, "with foo;" just means "every key in foo can be accessed without typing foo. in the next expression".
The result is basically: this file defines a function which takes an object containing the package repository as the "pkgs" key, and returns the result of calling pkgs.python3Packages.buildPythonApplication with the object defined in the rest of the file.
It's a lot more derived from the syntax of functional languages than C-like ones, but that's not necessarily a bad thing. Also: this is basically the entire language. There's a couple of different string syntaxes and some stuff for merging objects together, and also a mechanism for temporarily naming things that aren't part of an object, but in general... there's not a lot more to it. Most of the complexity is in the domain itself - what's the difference between a propagated, native and regular build input, how do you manage plugins and options for a package, etc.
What's your preferred packaging DSL?