How to unarchive/unpack a Nix archive (NAR) file?

nix nar cat is only able to cat an individual file in the NAR file. How can I extract everything in a NAR file at once? Is there a command for it?

cat file.nar | nix-store --restore path/to/extract/to

to unpack a *.nar.xz file

cat in.nar.xz | xz -dc | nix-store --restore out/
1 Like