One flake to rule them all
Flakes are here to stay, and the concept of one flake containing all others has been explored. Omniflake, a single flake input, carries nearly twelve thousand other flakes. This is possible due to the lazy nature of the Nix language and the flake lock mechanism. A flake is a directory with a flake.nix, which declares inputs and outputs, and a flake.lock that pinpoints the exact commit for each input.
The transitive graph, which shows dependencies between flakes, can become quite large, leading to duplicated inputs. However, follows can be used to unify these dependencies, allowing for a single shared copy of inputs like nixpkgs. The algorithm for creating such a megaflake works by remembering the highest suffix used per name and resuming from there, reducing the quadratic time complexity that would otherwise occur.
Despite this, the process still requires evaluating every input when creating the lock file. To overcome this, omniflake uses a JSONL file with pinned trees for all the flakes, avoiding the need for inputs altogether. When a specific flake is requested, omniflake fetches the pinned tree, reads its flake.nix, and evaluates it, resulting in a much faster and efficient process.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.