Mika Bohinen / NixCon 2026

The thunk trap

Open audience

Connecting presentation...

Current

The thunk trap

Why your Nix loop crashes after it finishes

Mika Bohinen - NixCon 2026

A dog insists this is fine while the room burns around him.Kleisli

Next

Sum requested memory. Generate the report when requested.

total is in MiB; makeReport lists service configurations missing a port
Code
diagnostics = makeReport entries;
initial = { total = 0; inherit diagnostics; };

sumStep = acc: entry: {
  total = acc.total + entry.memoryMiB;
  inherit diagnostics;
};
One call: the callback builds the next record
Accumulatortotal = 0diagnostics = makeReport entries
callback
Next accumulatortotal = 0 + 512diagnostics = the same report
becomes acc in the next call

Speaker notes

Introduce the memory total and optional diagnostic report as two fields carried by a capacity-planning tool.

Elapsed 0:00 / 5:00 budget
Overview

Arrow keys or Page Up / Page Down navigate. B blanks or restores the audience. F in the audience window toggles its fullscreen. Typing controls keep their keys. Timer recovery resumes paused.

Sum requested memory

Sum the memory requested by service configurations and keep a report of entries missing a port. The report is only needed when requested.

let
Definitions
n = 100000;
entries = builtins.genList
  (i: if builtins.bitAnd i 1 == 0
      then { memoryMiB = 512; }
      else { memoryMiB = 1024; port = 8080; }) n;
makeReport = entries: builtins.toJSON
  (builtins.filter (entry: !(entry ? port)) entries);
diagnostics = makeReport entries;
initial = { total = 0; inherit diagnostics; };
result = builtins.foldl'
  (acc: entry: { total = acc.total + entry.memoryMiB; inherit diagnostics; })
  initial entries;

Empty source

    Inspect the record's fields without asking for the memory total or the report.