Crate libnixstore
source ·Expand description
libnixstore
Is a library that provides simple access to your local nix store, based on c++ bindings. It mimics the already available perl bindings but also adds bindings on top, that might be useful.
Note: This project provides bindings, this makes the project automatically unsafe.
Supported nix version:
- nix 2.8
- nix 2.9
- nix 2.10
- nix 2.11
Requirements
It is only available for systems that have the nix package manager installed. To achieve this you should setup a simple shell.nix
with import <nixpkgs> { };
stdenv.mkDerivation {
name = "xyz";
nativeBuildInputs = [ rustc cargo gcc pkg-config ];
buildInputs = [
nix
nlohmann_json
libsodium
boost
rustfmt
clippy
];
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
}
Example
fn main() {
libnixstore::init();
println!("{}", libnixstore::get_store_dir());
}
Structs
Enums
Nix’s
libstore
offers two options for representing the
hash-part of store paths.Functions
Add a store path as a temporary root of the garbage collector. The root disappears as soon as
we exit.
This is the preparatory part of
addToStore()
;Verify that
sig
is a valid signature for msg
, using the signer’s public_key
.Returns all store paths in the file system closure of
storePath
Parse the hash from a string representation in the format
[<type>:]<base16|base32|base64>
or
<type>-<base64>
to a string representation of the hash, in base-16
, base-32
. The result
is not prefixed by the hash type.Read a derivation, after ensuring its existence through
ensurePath()
.Dump a store path in NAR format. The data is passed in chunks to callback
Export multiple paths in the format expected by
nix-store --import
.Follow symlinks until we end up with a path in the Nix store. Will transform the results to
store paths.
Return the path to the directory where the main programs are stored.
Return the build log of the specified store path, if available, or null otherwise.
Return a JSON representation as String of the contents of a NAR (except file contents).
Returns the path to the directory where nix store sources and derived files.
Compute the hash of the given file.
Compute the hash of the given path. The hash is defined as (essentially)
hashString(ht, dumpPath(path))
.Compute the hash of the given string.
Import a sequence of NAR dumps created by
export_paths()
into the Nix store. Optionally, the
contents of the NARs are preloaded into the specified FS accessor to speed up subsequent
access.Perform any necessary effectful operation to make the store up and running.
Check whether a path is valid.
Return deriver of a valid path. It is permitted to omit the name part of the store path.
Query the full store path given the hash part of a valid store path, or empty if the path
doesn’t exist.
Return narhash of a valid path. It is permitted to omit the name part of the store path.
Query information about a valid path. It is permitted to omit the name part of the store path.
The
radix
field affects only the narHash
field of the result.Query the information about a realisation
Return references of a valid path. It is permitted to omit the name part of the store path.
Set the loglevel.
Return a detached signature of the given string.
Sort a set of paths topologically under the references relation. If
p
refers to q
, then p
precedes q
in this list.