3 ms·
> I don't need to topologically sort the evaluation of the various inter-dependencies of my configuration. So long as there exists an evaluation order, laziness
by WastingMyTime89 4y ago
> I don't need to topologically sort the evaluation of the various inter-dependencies of my configuration. So long as there exists an evaluation order, laziness finds it.
That’s not a property of laziness but of how Nix evaluates configurations. I think people overvalue what laziness brings them because they attribute to it things which could be done equally well with an eager language.
- rssoconnor 4y agoThere is nothing special about how Nix evaluate system configurations that is any different from how Nix evaluates any other expression. Being able to write let usercfg = { username = "nix-user"; homedir = "/home/" + usercfg.username; }; in usercfg is nearly a hallmark of non-strict semantics, which is achieved by lazy evaluation. Strict languages can simulate these non-strict semantics by using functions of no parameters to delay evaluation, but you lose the efficiency that comes from the memoization of record fields that you get with lazy evaluation. P.S. The above would perhaps be more likely be written as rec { username = "nix-user"; homedir = "/home/" + username; } but when specifying larger configurations composed of multiple nested records with wide cross-cutting inter-dependencies, "rec" doesn't really cut it as "rec" works best with extremely local inter-dependencies.