I recently put together a Kaitai Struct spec for NAR format.
You can check it out here: GitHub - fzakaria/nix-nar-kaitai-spec: Kaitai Struct specification for the Nix Archive (.nar) format. and the spec file is specifically found at NAR.ksy
The codebase includes a test-suite to validate that it can parse and output similar contents as to what nix does.
Why?
Having a spec for things is another great way to clarify the structure of a format.
Although Kaitai generated code might not be optimized, it was pretty straight forward to implement the equivalent of nix nar ls which I have included in the repository.
This is in the same vein as the nix http binary cache API spec I also put together.
If you are experienced at Kaitai, I welcome improvements and test suite additions!