Module nix_compat::nar::writer::sync

source ·
Expand description

Implements an interface for writing the Nix archive format (NAR).

NAR files (and their hashed representations) are used in C++ Nix for addressing fixed-output derivations and a variety of other things.

NAR files can be output to any type that implements Write, and content can be read from any type that implementes BufRead.

Writing a single file might look like this:


// Output location to write the NAR to.
let mut sink: Vec<u8> = Vec::new();

// Instantiate writer for this output location.
let mut nar = nix_compat::nar::writer::open(&mut sink)?;

// Acquire metadata for the single file to output, and pass it in a
// `BufRead`-implementing type.

let executable = false;
let size = some_file.len() as u64;
let mut reader = BufReader::new(some_file.as_slice());
nar.file(executable, size, &mut reader)?;

Structs§

  • Content of a NAR node that represents a directory.
  • Content of a NAR node that represents a file whose contents are being written out manually. Returned by the file_manual_write function.
  • Single node in a NAR file.

Functions§

  • into_name 🔒
  • Create a new NAR, writing the output to the specified writer.

Type Aliases§