Comment

Comment by t0astbread

One use case for lazy evaluation in NixOS is that you can reference other parts of the system configuration, possibly even defined in other modules, as long as you don't produce cyclic references. For example, I use stuff like the following often to avoid accidentally specifying a username that does not exist:

  { config, ... }:
  {
   systemd.services.foobar = {
    enable = true;
    serviceConfig.User = config.users.users.foobar.name;
    # etc...
   };
  }
Another use case is being able to keep everything as plain values. For example, I can run `import <nixpkgs> { }` without evaluating all of `nixpkgs`. You can accomplish that in a language with eager evaluation by wrapping values in functions but I prefer the everything-is-a-value way.

Of course, this is just a matter of preference. Like most Guix vs. Nix aspects, as far as I can tell.

parent t0astbread 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton