Hacker News new | ask | show | jobs
by one-punch 810 days ago
Quoting https://nix.dev/tutorials/nix-language.html:

    The Nix language is designed for conveniently creating and composing derivations – precise descriptions of how contents of existing files are used to derive new files. It is a domain-specific, purely functional, lazily evaluated, dynamically typed programming language.
So, its key features are:

1. domain-specific: designed for conveniently creating and composing derivations. This reason alone already justifies a new language, or an embedded domain-specific language (embedded in the Guile/Scheme for guix), or a mix of both (Starlark, the build language of Bazel embedded in a restricted Python-variant).

2. purely functional: this underlies the philosophy of the Nix package manager, which aims to be purely functional (also known as hermeticity in other build systems, such as Bazel). Being purely functional in turn underlies the congruence of the NixOS operating system, where you declare what the state the system should be in (as opposed to being convergent, so that you specify how to achieve the desired state).

3. lazily evaluated: similar to other build systems (including Bazel), so that you can build only what you need on demand.

4. dynamically typed: this one is controversial. Being dynamically typed—in other words, not developing a type system—gets Nix out of the door 20 years ago. But users often complain about the lack of proper types and modularity. There are experiments to add a type-and-contract system to Nix, such as Nickel (https://github.com/tweag/nickel).

Most of the above are also listed in the Overview of the One Pager.

1 comments

Is it that much of a DSL when domain-specific primitives are mostly abstracted away in a standard library written in Nix itself, with underlying machinery written in shell, and when it heavily relies on shell and foreign config snippets to do the job?
Much of JavaScript's underlying machinery is also written in C++, how do you feel about that?
I usually don't need to write C++ when writing in JavaScript, though. Writing derivations in Nix in real world implies using the standard library and writing shell scripts for mkDerivation & co. ("domain specific" shell scripts that use stdenv)
Hmm, I write nix too, but never write shell within nix. Do you use it for custom builders?

How is using (nix?) standard library something that you don't want?