Repository navigation
feat(disko): add the caisson-disko and disko integrations - #91
Merged
Merged
Conversation
A disko configuration is a disk layout, with the NixOS configurations installed onto it declared inside it. Two integrations take it: - caisson-disko, the native one, owns the `caisson-disko` class. The layout is evaluated with caisson's own `evalModules` over `disko.devices`, typed with disko's type library, and the class adds `assertions`, which refuse a layout. Its outputs are the layout product: the device tree as data and its hash, the NixOS settings the devices produce, disko's metadata, and the scripts and packages for a package set. The NixOS configurations inside get the layout's `fileSystems`, `boot` and `swapDevices` through the registered NixOS module `caisson-disko-layout`, and nothing of disko. - disko, the upstream-compatible one, owns the `disko` class. A file written for disko is its module as it is. The NixOS configurations inside get the registered NixOS module `disko-layout`, which imports disko's NixOS module and defines `disko.devices` from the layout at default priority, so disko's command, `disko-install`, the image builder and the install test work on them. Both publish the layout as `diskoConfigurations.<name>`, the device tree with disko's internal attributes left out, which disko's command reads. Both pass up the NixOS configuration declared as `default` under the name of the layout, through `lib.caisson.integrations.renameDefault`. caisson-core is locked to nix-caisson/caisson-core#50, which keeps the eval-weight scenario under its ceiling with the two integrations added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nix-caisson/caisson-core#50 is merged; the locks move from its branch commit to its merge on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
caisson gets two disko integrations. In both, a disko configuration is a disk layout, and the NixOS configurations installed onto it are declared inside it:
caisson-disko, the native integrationcaisson-disko. The layout is evaluated with caisson's ownevalModulesoverdisko.devices, typed with disko's type library from the disko source the composition declares. This is the evaluator of ch-disko, brought into caisson.assertions({ assertion, message }, as in NixOS). A module of the class refuses a layout with one, and every output of the layout then fails with the messages. The hardware grounding moves to ch-hardware as a module of the class that uses them.serializableLayout,layoutHash,nixosConfig,meta,scriptsandpackages(each a function of a package set), androotMountPoint.caisson-disko-layoutto the machines inside. It definesfileSystems,bootandswapDevicesfrom the layout at default priority, and refuses a layout that produces settings under any other key. A machine gets nothing of disko itself, so the scripts that format and destroy disks are not reachable from it. The/etc/ch-diskoidentity files and thech-disko.*options are not carried over. A machine module that needs its layout reads it aslib.caisson-core.evalManifest.nearest.caisson-disko.disko, the upstream-compatible integrationdisko. A file written for disko is the module as it is, and the layout is evaluated as disko evaluates one on its own.disko-layoutto the machines inside. It imports disko's NixOS module from the same source and definesdisko.devicesfrom the layout at default priority. So disko's CLI againstnixosConfigurations,disko-install(which overrides the disks withmkVMOverride), the image builder and the install test work on the machine.Both
diskoConfigurations.<name>, as{ disko.devices = <serializableLayout>; }, which disko's CLI evaluates again with its own evaluator.defaultunder the name of the layout, with the newlib.caisson.integrations.renameDefault. So the machine installed ontonas-1is published asnixosConfigurations.nas-1, and is the nodenas-1of a colmena configuration that declares the layout. A layout that setscaisson.nixos.exportedoverrides that.Eval weight and caisson-core
The two integrations put the eval-weight scenario over its ceiling: caisson's overhead went from 4.06 MB to 4.45 MB against a 4.28 MB ceiling. Most of that cost came from caisson-core rebuilding the library for every module evaluation, and walking every overlay again each time. nix-caisson/caisson-core#50, now merged, walks a stage's overlays once. This branch locks caisson-core to its main, which has that change, and the overhead is 3.99 MB with the baseline unchanged.
Tests
The pinned-world suite pins disko and uses disko's example layouts as written:
caissonDiskoMachinesGetTheLayoutsSettings: a machine on a caisson-disko layout has nodiskooption and no disko scripts, is published under the name of the layout besidediskoConfigurations, and builds the same system as NixOS builds from disko's module and the same layout.caissonDiskoPublishesWhatDiskosCommandReads: disko's own evaluator makes the same format script from the published layout as from the layout as written (the example with mdadm, ZFS, LUKS and LVM), and thescriptsoutput is that script too.caissonDiskoLayoutsNeedNoMachineandcaissonDiskoAssertionsRefuseALayout.diskoMachinesGetDiskosModule: a machine on a disko layout hasconfig.disko.devicesand builds the same system and the same format script as NixOS builds from disko's module and the same layout, and an override withmkVMOverride, asdisko-installmakes, replaces the disks.diskoLayoutsInsideColmenaAreNodes: a layout inside a colmena configuration makes its machine the node named after the layout.A unit test covers
renameDefault. The signature tests and the argument-error suite cover both entry points.Verification
nix flake checkpasses, the eval-weight gate included.diskoand selects caisson'sdefaultmodule of that class. ch-disko's integration is retired in favour of these, and ch-hardware, its one consumer, moves tocaisson-disko, in follow-up pull requests.🤖 Generated with Claude Code