News for hackers. Stuff that matters.
Re:Guix: An advanced operating system by majewsky on Tuesday January 15, 2019 @03:20AM (#18909569)
> I also started using NixOS around Christmas time.

Hah, me too. :)

> I really love NixOS, but I'm at best lukewarm on Nix as a language.

My biggest issue as of now is that the documentation focuses on which individual files you need to touch, but doesn't really explain the big picture. For example, /etc/nixos/configuration.nix contains a function that takes { config, pkgs, ... }. Where do these come from? Where can I find documentation for them? What is in the ellipsis? More generally, where can I find a high-level overview of how the different components interact with each other during, for instance, nixos-rebuild?

Re:Guix: An advanced operating system by sterlind on Tuesday January 15, 2019 @03:53AM (#18909747)
All the quirks are little design patterns that look pretty weird at first, not language features themselves. The resource you're looking for is the Nix Pills series [0]. The LearnXInYMinutes on Nix is also a good overview of the syntax.[1] nix repl is also essential for feeling it out.

To answer your question, { config, pkgs, ... }: declares a function that takes an attribute set containing values for "config" and "pkgs". The ellipsis indicates that it's okay to pass extra attributes.

Nixos-rebuild calls your function by: with (import <nixpkgs> {}); callPackage ./configuration.nix {}

<nixpkgs> is a file containing the set of all symbols (packages are under pkgs, Nix config lives in config, etc.) like a root namespace. callPackage inherits all those symbols and passes them to the function, which is how they got bound.

0. https://nixos.org/nixos/nix-pills/index.html

1. https://learnxinyminutes.com/docs/nix/

EDIT: I guess it's also like Git where it's really confusing until a moment of enlightenment where it all makes sense.

Re:Guix: An advanced operating system by arianvanp on Tuesday January 15, 2019 @09:55AM (#18911477)
NixOS doesn't actually use callPackage. it uses lib.evalModules. The fact there is a difference between how NixOS is evaluated, vs how Nixpkgs is evaluated is something I actually find quite annoying. Whilst nixpkgs is all about functions and dependency injection, NixOS is all about merging dictionaries.

Here is some context, with corresponding criticsm by the person behind Guix, which might give some interesting insights

https://discourse.nixos.org/t/best-resources-for-learning-ab...