1.3 KiB
nixos-generate-facts - a data-driven alternative to nixos-generate-config
nixos-generate-config has two problems:
- It only ships on machines that already have Nix available.
- It outputs Nix code instead of data.
The first point is mostly relevant to cases where you want to bootstrap a new server with a remote tool like nixos-anywhere. It should be possible to gather the machine facts without first installing Nix. Otherwise there is a bootstrap problem.
The second point is for everybody. If instead of generating Nix code we would be generating a JSON-like data structure of facts about the machine. This can be recorded and loaded by Nix. Or added to the nixos-hardware repo. It can be used for user diagnostics. It inverts the control where the NixOS module system can now make decisions on which kernel modules to load over time.
Status: vaporware
The project is currently just a README.
The next step is going to generate the minimal binary and adapter so that I can replace my machine's hardware-configuration.nix
Once proven, I'm hoping to integrate that project upstream.
How the project works
The project has two parts:
- The binary that scans the system and outputs JSON or TOML.
- A NixOS module that can load that data and make decisions.
That's it.