[Nix-dev] wiki entry on how to add a large file into the nix store

Jonas Hörsch coroa at online.de
Fri Sep 13 15:02:16 CEST 2013


hi everyone,

i want to add more or less the following howto to the wiki. there is
just one question remaining, which i'd like to sort out beforehand,
namely what is the distinction between nix-store --add and
nix-prefetch-url and the resulting store paths?

would anyone care to enlighten me?

thanks,
jonas



to introduce a file into the nix store, you normally either use

nix-store --add largefile
or
nix-prefetch-url file://$(pwd)/largefile

but both procedures have the problem that they try to load the whole
file into memory, which may fail if you have a large one.

properly adding the file on your own is a three step procedure:

1. find the right store path:

   nix-store --print-fixed-path --recursive sha256 $(nix-hash --type \
   sha256 --base32 largefile) largefile

   to get the path which nix-store --add would be using

   nix-store --print-fixed-path sha256 $(nix-hash --type sha256 \
   --flat --base32 largefile) largefile

2. copy/move the file to this path (you have to remount the nix-store
   read-write)

3. register the file:

   nix-store --register-validity --reregister RET
   <store-path> RET
   RET
   0 RET
   C-d

what is unclear to me at this point is the distinction between the
path, that nix-store --add uses, and the one of nix-prefetch-url.

in a requireFile directive you need the nix-prefetch-url
one. the one from nix-hash --type sha256 --flat --base32, which needs
to be fed into nix-store without --recursive.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
Url : http://lists.science.uu.nl/pipermail/nix-dev/attachments/20130913/6d21a6f4/attachment.bin 


More information about the nix-dev mailing list