Skip to main content

nix_store_add_bytes_to_store

Function nix_store_add_bytes_to_store 

Source
pub unsafe extern "C" fn nix_store_add_bytes_to_store(
    context: *mut nix_c_context,
    store: *mut Store,
    name: *const c_char,
    data: *const c_uchar,
    data_len: usize,
    out_path: *mut *mut StorePath,
) -> nix_err
Expand description

Add raw bytes to the store as a flat, content-addressed file. Equivalent to Nix’s builtins.toFile, but accepts arbitrary bytes (including embedded NULs). The content is ingested with the “Text” content-addressing method (flat serialisation, SHA-256). The resulting store path has no references.

§Arguments

  • context [out] - Optional. Stores error information.
  • store [in] - Nix store reference.
  • name [in] - Name component of the store path (e.g. “my-file.bin”).
  • data [in] - Byte buffer to write. May be NULL iff data_len is 0.
  • data_len [in] - Length of the buffer in bytes.
  • out_path [out] - On success, set to the newly created StorePath. Free with nix_store_path_free.

§Returns

NIX_OK on success, otherwise a nix_err describing the failure.