13 ms·
Typing Nix
- k__ 9y agoNice. Half-OT: How is the new CLI coming along? AFAIK there was an effort to make Nix usage a bit more like known from other package managers.
- DonbunEf7 9y agoThere's an effort to make Nix's CLI better, but not necessarily like other package managers. The design is at https://gist.github.com/edolstra/efcadfd240c2d8906348 https://gist.github.com/edolstra/efcadfd240c2d8906348 The issue is at https://github.com/NixOS/nix/issues/779 https://github.com/NixOS/nix/issues/779
- k__ 9y agoOne year, and still not closed... Is this an ongoing process and most of it is already released or is this still in the making?
- aban 9y agoNeat. Somewhat related is hnix [0], a community effort in re-implementing the Nix expression language in Haskell. While so far the focus has mostly been on implementing the expression language as is, hnix being written in Haskell could be attractive for enriching the language with fancier features: "Because now that it's in Haskell, now that a lot of other hackers could get involved, we could do things like add optional typing to the Nix language." — J. Wiegley For more on hnix check out Haskell Cast's Episode 13 [1] with John Wiegley. [0]: https://github.com/jwiegley/hnix https://github.com/jwiegley/hnix [1]: http://www.haskellcast.com/episode/013-john-wiegley-on-categories-and-compilers http://www.haskellcast.com/episode/013-john-wiegley-on-categ...
- b__d 9y agoFunny: Nix is short (or colloquial) for "nichts" in German which further means "nothing" in English. So the CTA "Get Nix" is kinda funny for German speaking people :) PS: Greetings from Austria!
- atemerev 9y agoI love Nix. NixOS is my primary development operating system. However, the Nix language itself is syntactically ugly, and this proposal makes it even uglier. Parentheses, sigils and special characters (esp. semicolons) are line noise — the less of it the better. Why they wouldn't take the most (syntactically) beautiful functional programming language out there — Standard ML? It would work perfectly for such a task. Or the second contender — Haskell. If C-like syntax is desired, the best contendant is probably Swift. I cringe every time I have to edit a .nix file (and I have to do it a lot).
- jajern 9y agoIt's one of those languages that a developer can look at and think "Oh, so this is how non-developers see code".
- joombaga 9y agoIt looks like someone threw a pinch of erlang in a Chef recipe. Like bash, but every English word operator has been replaced by space ships, angry squids, ternary operators, && all the other things that make code hard to read. But... I still love Nix, and you get used to it.
- atemerev 9y agoBash is still worse. Probably. I know it is ubiquitous, but if I can avoid writing Bash scripts, I do.
- kmicklas 9y agoI have no idea why you would think that. It's pretty standard usage of punctuation like (){}[] etc. If it's hard to read that's because the libraries and infrastructure for writing derivations is not simple or well-documented. But that's not a language issue.
- agumonkey 9y agoYou tried guix ? I still have a fondness for sexps, but ML would be nice too.
- nosefouratyou 9y agoThere's also Guix in case anyone is interested. It uses Guile/Scheme for everything instead of Haskell.
- davexunit 9y agoI think that all the efforts to fix or re-implement the Nix language have vindicated Ludovic, the Guix maintainer, who chose an existing general-purpose language instead.
- geokon 9y agoExcept GUIX is more of a political project and part of the GNU "stack". It's a noble goal and I think it's great they're doing it. (It's people doing work on their spare time, so more power to them!) But I wonder if that will help or hinder it in the end. It's also unclear to me what Guile brings other than fracturing the Scheme/Lisp/Racket community further (there are other Schemes that are older, seemingly just as clean, and often more powerful). Seems like mostly NIMBYism, but I might be offbase
- akavel 9y agoBut Scheme is untyped too AFAIK - isn't it? So it'd require the same degree of "fixing" as long as we're talking about the discussed article.
- civodul 9y agoAs I explained in another comment, Scheme is indeed dynamically-typed (like Nix), but it's also strongly typed: one can define new data types, they are disjoint, and there can be no casts and the like. In Guix "packages" and "operating systems" are different types, you get a type error if you use one instead of the other; in Nix both are "attribute sets" (key/value dictionaries.) I think the one-type-fits-all ("attribute sets") vs. strong typing (disjoing record types) axis matters more than the static vs. dynamic axis here because most of the code (OS config files, package definitions, etc.) is loaded dynamically.
- mguijarr 9y agoHow does Nix compare with conda[0] ? I could not find any useful resource, in my team we were hesitating between the two, for packages management ; finally we went for conda because it (seems)is better documented and package description is easier to write for newbies. And also we are a Python shop, so other devs felt more comfortable with conda. Personally I prefer Nix, though, and I wanted to advocate for it but the only main difference I could find is that Nix sits on top of the kernel (including libc...) whereas conda uses the system libc. [0]: https://conda.io https://conda.io
- catern 9y agoI wrote this document: http://catern.com/posts/deps.html http://catern.com/posts/deps.html which briefly compares both Conda and Nix among other things. (warning: it's very pro-Nix :) )
- kalefranz 9y agoYou claim that conda "isn't very well supported by Unix as a whole" and "doesn't really work." Can you provide some evidence or examples to back up your claim?
- catern 9y agoSorry, I guess it basically requires you already know the ways in which Conda doesn't work. The basic problem is that Unix has a lot of hardcoded paths and no way to override them all at runtime. So you need to do lots of patching and hacks.
- emmelaich 9y agoThat is excellent, thanks. Double for mentioning Docker.
- gnufx 9y agoNot to put down Nix, but some of the arguments about other systems have counterexamples. For instance, it's common in rpm or dpkg distributions to have multiple versions and implementations of things, and richer dependencies than simply on packages. You can also do unprivileged installation into a separate root with, say, fakechroot or PRoot, and you need something like that to install and run Nix unprivileged, don't you? There are comparisons with alternatives in at least the propaganda for Spack and 0install, though the same criticism might apply to those -- I don't remember.
- adictator 9y agoIsn't containerization / Docker meant to solve this problem of configuration managers leaving machines in an unknown state? Nix seems to be a bandaid to config management solutions and is yet another kinda config management solution.
- dmix 9y ago> Configurations in Nix are written in a full-fledged programming language, featuring all manner of primitive datatypes (numbers, strings, file paths, etc), anonymous records and first-class functions. This is a very big deal for writing configurations in the large. Functions allow code reuse and abstraction, two crucial ingredients without which writing out configurations by hand would become unwieldy. Off topic but this brings up a good point I've been curious about for a long time. Does anyone know why VimL is such a terrible language? It's fascinating to think what potential it could have with a modern language natively supported like this. The use of Python/Lua etc seem like complicated hacks on top of it, not to mention the API with tons of globals.
- majewsky 9y agoSlightly related: Why does Github call Vimscript "VimL"?
- dmix 9y agoIt's not just Github, the Vim filetype is "viml". It's a standard name for the language. Most likely meaning Vim Language.
- majewsky 9y agoNo, it's not. The filetype is "vim", and the filetype detection code explicitly calls it "Vim script": https://github.com/vim/vim/blob/4670490673ed98502a09b74fbabe785b47e3d289/runtime/filetype.vim#L2384-L2385 https://github.com/vim/vim/blob/4670490673ed98502a09b74fbabe...
- dmix 9y agoYou're right, apologies, I was thinking of the Syntastic/Neomake plugin which both use "VimL" as an identifer, which I had just set up this past weekend and I mistook that as the Vim filetype identifier. Regardless Wikipedia says: > Vim script (also called vimscript or VimL) is the scripting language built into Vim. https://www.wikiwand.com/en/Vim_(text_editor)#/Vim_script https://www.wikiwand.com/en/Vim_(text_editor)#/Vim_script It's also colloquially referred to VimL across the web. For those looking for an answer, the 3rd result from googling "VimL" is a question on StackOverflow "Why does VimL suck?" which does a good job of answering my question: https://www.reddit.com/r/vim/comments/1bf672/why_does_viml_suck/ https://www.reddit.com/r/vim/comments/1bf672/why_does_viml_s...
- mellow_ 9y agoJust a heads up to the author that the link to Nixpkgs is not working, shows up as [Nixpkgs][nixpkgs] E: In the paragraph titled "NIX TODAY".
- regnat 9y agoThanks, it should be fixed now
- sly010 9y agoSure it would be nice to have types for refactoring, but a more useful set of features would be: - baked in fetchurl, fetchgit for easier bootstrapping - a functional dsl for rendering filesystem hierarchies - instead of the find/sed/awk galore. 50% of the time when my nix recipe breaks it's not a nix syntax issue but something with bash. (reading nix is an exercise in learning new unix features) - drop the channel feature entirely and make releases immutable tar files with hashes. I use nix as a build system on macos and right now a nix-channel update is a sure way to break all my builds which is the opposite of nix's promise EDIT: formatting
- regnat 9y agoFor your last point, you don't have to use the channels (which will anyway be deprecated at some point iirc), and you can pin the nixpkgs version in your nix files (like it is done in https://garbas.si/2015/reproducible-development-environments.html https://garbas.si/2015/reproducible-development-environments...)
- bennofs 9y agofor your first point., what about `builtins.fetchTarball` and `builtins.fetchurl` (`fetchgit` is in nix unstable afaik)
- ris 9y agoI'm pleasantly surprised to see so many Nix enthusiasts milling around in this thread and I'd like to encourage people to step up and do their part in helping improve and maintain nixpkgs. It's really not that hard, and it's the main area I would say Nix could do with some improvement. Adopt a package today!
- akavel 9y agoI tried doing some non-trivial contributions, and unfortunately there's currently some degree of a problem where there are not enough people actively revieving contributions and having enough authority in the project to be able to merge with confidence. Is it maybe not enough sponsorship for the project, compared to its popularity? Or does it not have a person with enough organisational experience in non-profits?
- vesak 9y agoI'd like to bring up another sort-of alternative: http://habitat.sh http://habitat.sh It's not exactly in the same space as Nix, but not very far from it, either. In Habitat, you use a language that felt to me quite similar to Arch Linux's PKGBUILDs, but extended with container-specific things like service ports etc. Habitat outputs containers that can be started in various orchestration technologies, like Kubernetes or Mesos/Marathon.
- ungzd 9y agoIt's interesting and very similar to Nix, but I still didn't figure out purpose of it, especially why it heavily uses Docker. Many people use Docker for the same functionality that Nix provides: bundling application with its dependencies, not for isolating groups of processes from each other.
- vesak 9y agoDocker images is one of the supported formats when exporting packages. Others at the moment are aci, mesos and tarball.
- civodul 9y agoThe problem with Nix in terms of typing is that it relies a lot on key/value dictionaries ("attribute sets" in Nix parlance). These data structures are dynamic in nature. All a static type checker can say is "yeah this is an attribute set". In addition, Nix does not offer a way to define new disjoint data types. Conversely in Guix most of the data structures are disjoint record types. Scheme (the implementation language of Guix) is dynamically-typed, but there are sanity checks we can do on records both at macro-expansion time and at run time, such as checking whether all the required fields are defined and no extra field is passed. Concretely, this means that users get clear syntax errors or run-time type errors. Nix and Scheme are both dynamically typed, but they have a different typing story. Disclaimer: Guix hacker here.