Hi, I’m trying to pack some pre-built binary files into a derivation. However, foo.img and bar.imgalways copied to /nix/store/<hash>-{foo,bar}.img. Is there a way to eliminate this, only keeping the final result (/nix/store/<hash>-mypkg/data/foo.img)? Like what writeTextDirdoes.
If those files do not contain nulls, it is technically possible with builtins.readFile, but I don’t recommend it. Just run garbage collection afterwards and it should delete the intermediate files.
Can you specify why those files being created is a problem?
Also, I’d recommend using pkgs.runCommand rather than builtins.derivation. Just simpler.
After executing nix-collect-garbage -d they still exists (/nix/store/<hash>-{foo,bar}.img). I’ve added mypkg to environment.systemPackages. Is it related?
Well, they’d only still exist after garbage collection if something retained a link to them. mypkg wouldn’t retain such a link, the way you’ve written it, so presumably it’s something else.