!djTaTBQyWEPRQxrPTb:nixos.org

Nixpkgs Architecture Team

229 Members
https://github.com/nixpkgs-architecture, weekly public meetings on Wednesday 15:00-16:00 UTC at https://meet.jit.si/nixpkgs-architecture51 Servers

Load older messages


SenderMessageTime
12 Jul 2023
@yannham:matrix.org@yannham:matrix.org

Ah, funny to see that a lot of the subjects touched upon here are questions we also had to think about for Nickel as well. Would be interesting to share some of the ideas and insights on both side. A couple points:

  • We have Profpatsch 's approach to defaults and forces: those are just priorities. But in Nickel priorities are builtin, and somehow orthogonal to the value (stored inside metadata), so the interpreter just transparently ignores them. That is, {foo | default = 5}.foo is just 5, without having to care about the priority. To override it, you need to merge it with something else which defines a new value for foo.
  • I think that some form of static dependency tracking is important as well. Because scoping is lexical, we mostly use free variables, which seems to be a reasonable over approximation (that is, you can determine statically what fields in the final fixpoint another field depend on). I guess you could even be smarter about record accesses (if you only see options.bar and options.baz, then you can avoid depending on options.whatever and other fields).This also paves the way for incremental evaluation.

merging is different from typechecking
conflating the two is a big source of annoyance

07:22:24
@yannham:matrix.org@yannham:matrix.org Profpatsch: would you care elaborating on that? CUE seems to take the entirely opposed approach 07:22:44
@yannham:matrix.org@yannham:matrix.org * Profpatsch: would you mind elaborating on that please? CUE seems to take the entirely opposed approach 07:24:43
@yannham:matrix.org@yannham:matrix.org *

Ah, funny to see that a lot of the subjects touched upon here are questions we also had to think about for Nickel as well. Would be interesting to share some of the ideas and insights on both sides. A couple points:

  • We have Profpatsch 's approach to defaults and forces: those are just priorities. But in Nickel priorities are builtin, and somehow orthogonal to the value (stored inside metadata), so the interpreter just transparently ignores them. That is, {foo | default = 5}.foo is just 5, without having to care about the priority. To override it, you need to merge it with something else which defines a new value for foo.
  • I think that some form of static dependency tracking is important as well. Because scoping is lexical, we mostly use free variables, which seems to be a reasonable over approximation (that is, you can determine statically what fields in the final fixpoint another field depends on). I guess you could even be smarter about record accesses (if you only see options.bar and options.baz, then you can avoid depending on options.whatever and other fields).This also paves the way for incremental evaluation.

merging is different from typechecking
conflating the two is a big source of annoyance

07:33:02
@yannham:matrix.org@yannham:matrix.org changed their display name from Yann Hamdaoui to yannham.07:46:09
@profpatsch:augsburg.oneprofpatschyannham: Cue suffers from the same slowness problems as the nixos module system afaik08:41:28
@profpatsch:augsburg.oneprofpatschThe problem is unscoped merging, aka if you want to figure out whether something exists, you have to potentially search through every module definition08:42:25
@profpatsch:augsburg.oneprofpatschPriority is a pretty horrible monoid, because you cannot use laziness to short-circuit08:42:43
@profpatsch:augsburg.oneprofpatschcompared to e.g. Last08:42:54
@profpatsch:augsburg.oneprofpatsch(there could always be something with higher priority that the evaluator hasn’t seen yet, so you have to look at absolutely everything)08:43:33
@profpatsch:augsburg.oneprofpatschI don’t know how nickel solves this?08:43:57
@nbp:mozilla.orgnbp Almost the same story for SOS, the intent was to not remove mkDerivation but delay it to be executed at the very end of the fix-point, thus making packages just ordinary attribute sets available through prev/super, which can be overwritten by using Nix's update operator within Nixpkgs' overlays. 10:00:03
@piegames:matrix.org@piegames:matrix.org
In reply to @nbp:mozilla.org
Almost the same story for SOS, the intent was to not remove mkDerivation but delay it to be executed at the very end of the fix-point, thus making packages just ordinary attribute sets available through prev/super, which can be overwritten by using Nix's update operator within Nixpkgs' overlays.
How does this deal with e.g. Python packages? I like the idea but again I don't think this is going to work well until we've foxed our builders
10:16:18
@profpatsch:augsburg.oneprofpatschUnrelated, but one change I’d like to see is having features be a special attribute set, and each feature ideally carries the information which dependencies it needs.10:58:16
@profpatsch:augsburg.oneprofpatschThat way static information is available. Question is whether this would be done symbolically (by projecting it out of the fixpoint as is the case now) or by-name (as a string)10:59:14
@nbp:mozilla.orgnbp

by flattening python packages under the top-level fix-point. What these python sets are is a custom python package with a set of python packages relying on these.

To make it short, this is providing only a different scope from which packages are taken from. I opened a PR on this topic a while ago. https://github.com/NixOS/nixpkgs/pull/44196

An alternative would be to make inherited inputs. For example:

{
  python99Packages = {
    __scope = { buildInputs = { python = …; }; }
  };
}

In which case one could assume that the last scope definition overrides the package inputs, unless override by the user with the update operator.

We have many options to choose from.

11:00:32
@nbp:mozilla.orgnbp These __scope would again be resolved last, only if the name is not explicitly bound on the packages inputs. 11:01:52
@piegames:matrix.org@piegames:matrix.org No I was talking about builders like PythonPackage, not the package set itself 11:04:10
@nbp:mozilla.orgnbpThen I do not know, nor see how it would be different than today.11:05:14
@piegames:matrix.org@piegames:matrix.org Well the situation of today is pretty bad, so I hope it would be different 11:06:31
@hexa:lossy.networkhexasimple paths when13:33:53
@phaer:matrix.orgphaerRFC is merged 🎉13:46:11
@phaer:matrix.orgphaeras of 12 mins ago https://github.com/NixOS/rfcs/pull/140#event-979957369013:46:28
@piegames:matrix.org@piegames:matrix.orgYes.13:46:39
* @piegames:matrix.org@piegames:matrix.org is hovering over the green button at the implementation PR13:46:57
@phaer:matrix.orgphaerYes, "just" the implementation work left 😄13:47:50
@phaer:matrix.orgphaerhttps://github.com/NixOS/nixpkgs/pull/237439 13:48:08
@yannham:matrix.org@yannham:matrix.org

Cue suffers from the same slowness problems as the nixos module system afaik

On the performance matter, it's not really related to modules per se but in general I personally have high hopes in the incremental evaluation approach. It's less of an issue that your evaluation from scratch is slow, under the hypothesis that each new generation is just a small diff from the previous one, and that your interpreter can reuse most of the previous results incrementally. Lazy evaluation turns out to play quite well with incremental evaluation (basically, you can more or less swap the evaluator with a one performing various caching strategies without changing the semantics of the language). But hard to tell before trying this at scale.

The problem is unscoped merging, aka if you want to figure out whether something exists, you have to potentially search through every module definition

I might be misunderstanding, but I feel like it's more of a NixOS module system design decision (put everything in one big fixpoint soup), rather than something inherent to merging as defined e.g. in CUE ? Couldn't you build a more scoped/hierarchical system based on CUE for example (or even in pure Nix)?

14:59:02
@nbp:mozilla.orgnbp yannham: Actually, one case where maximal-laziness this would shine a lot is on the nixos/maintainers/option-usages.nix expression, where NixOS evaluation is re-done completely with one option changed, and evaluating whether one option is used as part of the computation. This was one of my assumption, until I realize that the feature got removed :( 15:25:18
@nbp:mozilla.orgnbpWhat is CUE?15:26:16

Show newer messages


Back to Room ListRoom Version: 9