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 = [
# required
nix
nlohmann_json
libsodium
boost
# additional packages you might need
rustfmt
clippy
# ...
];
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
}
§Example
fn main() {
libnixstore::init();
println!("{}", libnixstore::get_store_dir());
}
Structs§
Enums§
- Radix
- Nix’s
libstore
offers two options for representing the hash-part of store paths.
Functions§
- add_
temp_ root - Add a store path as a temporary root of the garbage collector. The root disappears as soon as we exit.
- add_
to_ store - This is the preparatory part of
addToStore()
; - check_
signature - Verify that
sig
is a valid signature formsg
, using the signer’spublic_key
. - compute_
fs_ closure - Returns all store paths in the file system closure of
storePath
- convert_
hash - Parse the hash from a string representation in the format
[<type>:]<base16|base32|base64>
or<type>-<base64>
to a string representation of the hash, inbase-16
,base-32
. The result is not prefixed by the hash type. - derivation_
from_ path - Read a derivation, after ensuring its existence through
ensurePath()
. - dump_
path - Dump a store path in NAR format. The data is passed in chunks to callback
- export_
paths - Export multiple paths in the format expected by
nix-store --import
. - follow_
links_ to_ store_ path - Follow symlinks until we end up with a path in the Nix store. Will transform the results to store paths.
- get_
bin_ dir - Return the path to the directory where the main programs are stored.
- get_
build_ log - Return the build log of the specified store path, if available, or null otherwise.
- get_
nar_ list - Return a JSON representation as String of the contents of a NAR (except file contents).
- get_
store_ dir - Returns the path to the directory where nix store sources and derived files.
- hash_
file - Compute the hash of the given file.
- hash_
path - Compute the hash of the given path. The hash is defined as (essentially)
hashString(ht, dumpPath(path))
. - hash_
string - Compute the hash of the given string.
- import_
paths - 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. - init
- Perform any necessary effectful operation to make the store up and running.
- is_
valid_ path - Check whether a path is valid.
- make_
fixed_ output_ path - query_
deriver - Return deriver of a valid path. It is permitted to omit the name part of the store path.
- query_
path_ from_ hash_ part - Query the full store path given the hash part of a valid store path, or empty if the path doesn’t exist.
- query_
path_ hash - Return narhash of a valid path. It is permitted to omit the name part of the store path.
- query_
path_ info - Query information about a valid path. It is permitted to omit the name part of the store path.
The
radix
field affects only thenarHash
field of the result. - query_
raw_ realisation - Query the information about a realisation
- query_
references - Return references of a valid path. It is permitted to omit the name part of the store path.
- set_
verbosity - Set the loglevel.
- sign_
string - Return a detached signature of the given string.
- topo_
sort_ paths - Sort a set of paths topologically under the references relation. If
p
refers toq
, thenp
precedesq
in this list.