4 ms·
I like Scheme, but I think a lot of people actually wouldn’t want to write their packages and OS configuration files as S-expressions. Nix is an extremely simp
by mbrock 8y ago
I like Scheme, but I think a lot of people actually wouldn’t want to write their packages and OS configuration files as S-expressions.
Nix is an extremely simple language with quite familiar syntax, a kind of JSON with functions and string interpolation.
Note also that Guix uses Scheme a lot more deeply than Nix uses the Nix language, in the sense that Nix uses e.g. shell scripts where Guix uses Scheme statements. Actual “coding” in the Nix language is relatively rare.
- akavel 8y agoFor me personally, as a person who's tried Nix, it's helpful that the Nix language is simple, self contained and easy to learn & grok quickly. I never learnt Scheme, and its use in Guix, though extremely interesting and appealing in theory, also feels notably overwhelming to me. That I'd have to learn a whole (presumably huge) R7RS or something, just to be able to use Guix. And then still have to learn the Guix "API" or DSL over that to be able to actually use it. While the Nix language is small and fully described in the Nix manual, in surprisingly few words.
- rekado 8y agoDisclaimer: 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 has a bunch of utility procedures that are useful extensions to their Scheme counterparts, such as `mkdir-p` (which does what you think it does) or the `substitute*` form to substitute expressions in a file or list of files. One important difference between Nix and Guix is that Guix does not glue shell snippets together, but eventually compiles to Guile builder scripts, so it's Scheme all the way down.
- mbrock 8y agoDoes 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. This ability seems like it would have huge implications for system development... I've dabbled with such experiments using Nix, but the lack of hygienic code staging makes it a bit icky.
- rekado 8y agoI 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-Composition.html http://www.gnu.org/software/guix/manual/en/html_node/Service...
- aidenn0 8y ago"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 lazy evaluation is not necessary). Even tiny things like "sets" as a name for an associative data type make it just that much harder to learn.
- skybrian 8y agoI 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?
- aidenn0 8y agoYes, this primer would have been very helpful at the time. It's not like it's impossible to learn, but "familiar" it is not.
- binaryphile 8y agoI 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.