go-nix
go-nix copied to clipboard
introduce Narfuse for fun
I banged this together until it worked. And it works! The code is quite garbage right now, but it was fun, and I learned a few things.
go-fuse wants to build the filesystem structure when mounted. Then later, when individual files get accessed, there is a callback to read the content. There are multiple ways to handle this, but I wanted to avoid keeping the whole NAR in memory, so I added the Offset to the nar.Header. This allows the first pass to read the NAR file for the headers and build the filesystem layout. Then later, when individual files get read, re-open the NAR file, seek at Offset and read up to Size.
Once I did this, I found that the nar/ls.Node structure also has an offset. Maybe better to use that, but right now we're missing a method that converse the NAR to a nar/ls structure. That's something I might do in another iteration.