To manually add a file to the store, use the following command
nix-store --add-fixed sha256 <file-name>.tar.gzThe hash can be calculated using
nix-hash --type sha256 --flat <file-name>.tar.gzFiles retrieved by one of the nix builtin functions, typically don't add the
--flat option, which in this case would hash the compressed file, but instead
hash the decompressed files.
We could then make use of this artifact, for example, as the src for another
derivation.
stdenv.mkDerivation rec {
name = "test";
version = "0.0.1";
pname = "${name}-${version}";
src = prev.requireFile {
name = "<file-name>.tar.gz";
url = "<url-to-retrieve-file-if-not-available-in-store>";
sha256 = "<hash-from-nix-hash-command>";
};
}