Live data from Hacker News

Nix Language Primer

binaryphile.com

61–69 of 69 posts

Re: Nix Language Primer

#61
post #60

I switched all of my machines to NixOS for a few months. It was a wonderful experience being able to keep all my environments in sync. Nix the language is one reason I reverted to Ubuntu a few weeks ago. It just didn't mesh well with me....so when the inevitable problem occurred, it was a pain to deal with. Other pain points: - the NixOS learning curve is steep. There are two many tools with too many obscure options…

Imagine if all the right ideas from nix were taken out and combined with supervision trees, we would have super reliable distros and PaaS style one click infrastructure.

Re: Nix Language Primer

#62
post #54

Earlier quoted context omitted.

"familiar syntax"? Perhaps if you use Haskell or ML. That's probably a tie with s-expressions for popular syntax, but definitely not familiar to most people. I really like nix the package manager and like NixOS the distribution, but learning nix the language was an awful lot of work, and I'm not convinced that it couldn't have been accomplished with a language that is more familiar (Guix demonstrates that baked-in la…

I haven't used nix, but this primer seems pretty straightforward. Was the learning curve you faced perhaps due to missing or hard-to-find documentation at the time, or something else?

I can relate to the earlier poster because I had the same problem finding all of these rules in one place. I wrote it to be precisely what I wish someone had told me before I got started.

Thank you for the compliment btw.

Re: Nix Language Primer

#63
post #2

Does anyone know the rationale for creating Nixlang? Guix's use of Scheme proves there isn't a novel feature unavailable elsewhere, so it seems like a lot of wasted effort to implement a language that will likely only ever be used for one suite of programs. (And tooling; though almost none exists now, making the choice even more expensive.) I've tried to find one, but "nix" is a difficult thing to google for given th…

This is the first I've heard of Nix. A quick search reminded me that it has nothing to do with Nim, and turned up NixOS that I have heard of.

Here's a good description of why I should care: https://yakking.branchable.com/posts/what-and-why-nix/

Re: Nix Language Primer

#64
post #51

I don't understand why any languages exist for describing packages, its a layer above describing real dependencies like with make, ninja, etc. Just have an os written in something like premake but with a nicer DSL.

It allows to have some guarantees around the evaluation. The Nix expression language enforces things like not allowing arbitrary network access during evaluation. This is hard to do in a general-purpose language where network and file access are usually backed in.

This is easily done by chain-loading and system()

Re: Nix Language Primer

#65
post #44

Earlier quoted context omitted.

Because nobody want to program in (((( Guile )))), to the point that even GDB disable its support as extension language.

However undesirable it appears at first, it does prevent the creation of an infinite number of new, incompatible languages. Config languages tend toward turing completeness and just become turing tarpits. That's why I'm asking about using a Lisp which is extendable to its problem domain. Source on gdb disabling it? Just writing `gr` in gdb enters the guile repl.

It has been disable by default and is not even compiled-in anymore on all major linux distributions ( RHEL, Debian, ubuntu ).

>(gdb) gr Guile scripting is not supported in this copy of GDB.

Re: Nix Language Primer

#66

Earlier quoted context omitted.

Nobody wants an arbitrary complex program for describing some trivial build steps. A programming language here is an anti-feature. Ideal would be some DSL that isn't even Turing complete, but that's not practical at the moment. Maybe we'll get there some day.

Really what no one wants is a build step that takes forever. I'm more upset about how long nix-env -i takes than what the computational complexity of the programming language is

nix-env -i is slow because it has to evaluate every package definition. nix-env -iA is way faster.

Re: Nix Language Primer

#67
post #65

Earlier quoted context omitted.

However undesirable it appears at first, it does prevent the creation of an infinite number of new, incompatible languages. Config languages tend toward turing completeness and just become turing tarpits. That's why I'm asking about using a Lisp which is extendable to its problem domain. Source on gdb disabling it? Just writing `gr` in gdb enters the guile repl.

It has been disable by default and is not even compiled-in anymore on all major linux distributions ( RHEL, Debian, ubuntu ). >(gdb) gr Guile scripting is not supported in this copy of GDB.

What's your version? I'm on 8.2

Re: Nix Language Primer

#68
post #36
post #28

Earlier quoted context omitted.

Disclaimer: as a Guix co-maintainer I'm totally biased. We don't use R7RS in Guix. You need to know about the Scheme syntax, obviously (including keyword arguments), and a couple of common procedures like `string-append`, but aside from that you don't really need to know much about Scheme at all. What comes in handy is the Guix DSL, which provides a convenient way to specify packages and download origins. Guix also h…

Does Guix let you write interactive programs in Scheme as part of the system configuration? For example, defining a systemd service that uses Guile libraries and so on, as a subexpression of your OS configuration file? While also referring to shared variables like the system's hostname, etc? I skimmed the paper on "Code Staging in Guix" and I think this should be very doable, but I haven't yet tried Guix for real. Th…

I don't know about interactive programs; in Guix we like system configuration to be non-interactive.

We don't use systemd but the Shepherd, which is written in Guile Scheme, so system services are indeed written in Scheme and can use Guile libraries. It is a common pattern to define services as the result of procedures taking variables as arguments.

System services in Guix don't have to be limited to Shepherd services. The system service framework in Guix is very flexible and can be used for almost any system setup task, even for mere "activation services" that create directories or files. Services can extend other services:

http://www.gnu.org/software/guix/manual/en/html_node/Service...

Re: Nix Language Primer

#69
post #42

A few correction on the otherwise good article: * Nix 2.0 includes the repl. Just run `nix repl` * The URL literal returns a string * It would be good to explain how the ` ` notation resolves paths from the NIX_PATH. For example ` ` looks for the `nixpkgs` key in `NIX_PATH=nixpkgs=/path/to/channel`

Finally got around to updating the post with your suggestions. Thanks again.
Post reply on HN