Skip to content

Commit aa248fd

Browse files
Mic92mergify[bot]
authored andcommitted
drop all ffi functions not used by harmonia
1 parent 96145da commit aa248fd

File tree

3 files changed

+0
-204
lines changed

3 files changed

+0
-204
lines changed

libnixstore/include/nix.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,8 @@ namespace libnixstore {
77
void init();
88
bool is_valid_path(rust::Str path);
99
rust::String query_path_hash(rust::Str path);
10-
rust::String query_deriver(rust::Str path);
1110
InternalPathInfo query_path_info(rust::Str path, bool base32);
12-
rust::String query_raw_realisation(rust::Str output_id);
1311
rust::String query_path_from_hash_part(rust::Str hash_part);
14-
rust::Vec<rust::String> compute_fs_closure(bool flip_direction,
15-
bool include_outputs,
16-
rust::Vec<rust::Str> paths);
17-
rust::Vec<rust::String> topo_sort_paths(rust::Vec<rust::Str> paths);
18-
rust::String follow_links_to_store_path(rust::Str path);
1912
void export_paths(int32_t fd, rust::Vec<rust::Str> paths);
2013
void import_paths(int32_t fd, bool dont_check_signs);
2114
rust::String hash_file(rust::Str algo, bool base32, rust::Str path);

libnixstore/src/lib.rs

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,16 @@ mod ffi {
3838
unsafe extern "C++" {
3939
include!("libnixstore/include/nix.h");
4040

41-
// bindings that are also available in the perl bindings
4241
fn init();
4342
fn is_valid_path(path: &str) -> Result<bool>;
4443
fn query_path_hash(path: &str) -> Result<String>;
45-
fn query_deriver(path: &str) -> Result<String>;
4644
fn query_path_info(path: &str, base32: bool) -> Result<InternalPathInfo>;
47-
fn query_raw_realisation(output_id: &str) -> Result<String>;
4845
fn query_path_from_hash_part(hash_part: &str) -> Result<String>;
49-
fn compute_fs_closure(
50-
flip_direction: bool,
51-
include_outputs: bool,
52-
paths: Vec<&str>,
53-
) -> Result<Vec<String>>;
54-
fn topo_sort_paths(paths: Vec<&str>) -> Result<Vec<String>>;
55-
fn follow_links_to_store_path(path: &str) -> Result<String>;
56-
fn export_paths(fd: i32, paths: Vec<&str>) -> Result<()>;
57-
fn import_paths(fd: i32, dont_check_signs: bool) -> Result<()>;
58-
fn hash_file(algo: &str, base32: bool, path: &str) -> Result<String>;
59-
fn hash_string(algo: &str, base32: bool, s: &str) -> Result<String>;
6046
fn convert_hash(algo: &str, s: &str, to_base_32: bool) -> Result<String>;
6147
fn sign_string(secret_key: &str, msg: &str) -> Result<String>;
6248
fn check_signature(public_key: &str, sig: &str, msg: &str) -> Result<bool>;
6349
fn derivation_from_path(drv_path: &str) -> Result<InternalDrv>;
64-
fn add_temp_root(store_path: &str) -> Result<()>;
65-
fn get_bin_dir() -> String;
6650
fn get_store_dir() -> String;
67-
68-
// additional but useful for harmonia
6951
fn get_build_log(derivation_path: &str) -> Result<String>;
7052
fn get_nar_list(store_path: &str) -> Result<String>;
7153
}
@@ -157,16 +139,6 @@ pub fn query_path_hash(path: &str) -> Result<String, cxx::Exception> {
157139
ffi::query_path_hash(path)
158140
}
159141

160-
#[inline]
161-
#[must_use]
162-
/// Return deriver of a valid path. It is permitted to omit the name part of the store path.
163-
pub fn query_deriver(path: &str) -> Option<String> {
164-
match ffi::query_deriver(path) {
165-
Ok(v) => string_to_opt(v),
166-
Err(_) => None,
167-
}
168-
}
169-
170142
#[inline]
171143
/// Query information about a valid path. It is permitted to omit the name part of the store path.
172144
/// The `radix` field affects only the `narHash` field of the result.
@@ -183,16 +155,6 @@ pub fn query_path_info(path: &str, radix: Radix) -> Result<PathInfo, cxx::Except
183155
})
184156
}
185157

186-
#[inline]
187-
#[must_use]
188-
/// Query the information about a realisation
189-
pub fn query_raw_realisation(output_id: &str) -> Option<String> {
190-
match ffi::query_raw_realisation(output_id) {
191-
Ok(v) => string_to_opt(v),
192-
Err(_) => None,
193-
}
194-
}
195-
196158
#[inline]
197159
#[must_use]
198160
/// Query the full store path given the hash part of a valid store path, or empty if the path
@@ -204,61 +166,6 @@ pub fn query_path_from_hash_part(hash_part: &str) -> Option<String> {
204166
}
205167
}
206168

207-
#[inline]
208-
/// Returns all store paths in the file system closure of `storePath`
209-
///
210-
/// That is, all paths than can be directly or indirectly reached from it. If `flip_direction` is
211-
/// true, the set of paths that can reach `storePath` is returned; that is, the closures under the
212-
/// `referrers` relation instead of the `references` relation is returned. If `include_outputs` is
213-
/// `true` then closure will additionally include all outputs of every derivation in the closure.
214-
pub fn compute_fs_closure(
215-
flip_direction: bool,
216-
include_outputs: bool,
217-
paths: Vec<&str>,
218-
) -> Result<Vec<String>, cxx::Exception> {
219-
ffi::compute_fs_closure(flip_direction, include_outputs, paths)
220-
}
221-
222-
#[inline]
223-
/// Sort a set of paths topologically under the references relation. If `p` refers to `q`, then `p`
224-
/// precedes `q` in this list.
225-
pub fn topo_sort_paths(paths: Vec<&str>) -> Result<Vec<String>, cxx::Exception> {
226-
ffi::topo_sort_paths(paths)
227-
}
228-
229-
#[inline]
230-
/// Follow symlinks until we end up with a path in the Nix store. Will transform the results to
231-
/// store paths.
232-
pub fn follow_links_to_store_path(path: &str) -> Result<String, cxx::Exception> {
233-
ffi::follow_links_to_store_path(path)
234-
}
235-
236-
#[inline]
237-
/// Export multiple paths in the format expected by `nix-store --import`.
238-
pub fn export_paths(fd: i32, paths: Vec<&str>) -> Result<(), cxx::Exception> {
239-
ffi::export_paths(fd, paths)
240-
}
241-
242-
#[inline]
243-
/// Import a sequence of NAR dumps created by `export_paths()` into the Nix store. Optionally, the
244-
/// contents of the NARs are preloaded into the specified FS accessor to speed up subsequent
245-
/// access.
246-
pub fn import_paths(fd: i32, dont_check_signs: bool) -> Result<(), cxx::Exception> {
247-
ffi::import_paths(fd, dont_check_signs)
248-
}
249-
250-
#[inline]
251-
/// Compute the hash of the given file.
252-
pub fn hash_file(algo: &str, radix: Radix, path: &str) -> Result<String, cxx::Exception> {
253-
ffi::hash_file(algo, matches!(radix, Radix::Base32), path)
254-
}
255-
256-
#[inline]
257-
/// Compute the hash of the given string.
258-
pub fn hash_string(algo: &str, radix: Radix, s: &str) -> Result<String, cxx::Exception> {
259-
ffi::hash_string(algo, matches!(radix, Radix::Base32), s)
260-
}
261-
262169
#[inline]
263170
/// Parse the hash from a string representation in the format `[<type>:]<base16|base32|base64>` or
264171
/// `<type>-<base64>` to a string representation of the hash, in `base-16`, `base-32`. The result
@@ -304,20 +211,6 @@ pub fn derivation_from_path(drv_path: &str) -> Result<Drv, cxx::Exception> {
304211
})
305212
}
306213

307-
#[inline]
308-
/// Add a store path as a temporary root of the garbage collector. The root disappears as soon as
309-
/// we exit.
310-
pub fn add_temp_root(store_path: &str) -> Result<(), cxx::Exception> {
311-
ffi::add_temp_root(store_path)
312-
}
313-
314-
#[inline]
315-
#[must_use]
316-
/// Return the path to the directory where the main programs are stored.
317-
pub fn get_bin_dir() -> String {
318-
ffi::get_bin_dir()
319-
}
320-
321214
#[inline]
322215
#[must_use]
323216
/// Returns the path to the directory where nix store sources and derived files.

libnixstore/src/nix.cpp

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,6 @@ rust::String query_path_hash(rust::Str path) {
9393
->narHash.to_string(nix::HashFormat::Nix32, true);
9494
}
9595

96-
rust::String query_deriver(rust::Str path) {
97-
auto store = get_store();
98-
nix::ref<const nix::ValidPathInfo> info =
99-
store->queryPathInfo(store->parseStorePath(STRING_VIEW(path)));
100-
return extract_opt_path(info->deriver);
101-
}
102-
10396
InternalPathInfo query_path_info(rust::Str path, bool base32) {
10497
auto store = get_store();
10598
nix::ref<const nix::ValidPathInfo> info =
@@ -128,85 +121,11 @@ InternalPathInfo query_path_info(rust::Str path, bool base32) {
128121
};
129122
}
130123

131-
rust::String query_raw_realisation(rust::Str output_id) {
132-
std::shared_ptr<const nix::Realisation> realisation =
133-
get_store()->queryRealisation(
134-
nix::DrvOutput::parse(STRING_VIEW(output_id)));
135-
if (!realisation) {
136-
// TODO(conni2461): Replace with option
137-
return "";
138-
}
139-
return realisation->toJSON().dump();
140-
}
141-
142124
rust::String query_path_from_hash_part(rust::Str hash_part) {
143125
return extract_opt_path(
144126
get_store()->queryPathFromHashPart(STRING_VIEW(hash_part)));
145127
}
146128

147-
rust::Vec<rust::String> compute_fs_closure(bool flip_direction,
148-
bool include_outputs,
149-
rust::Vec<rust::Str> paths) {
150-
auto store = get_store();
151-
nix::StorePathSet path_set;
152-
for (auto &path : paths) {
153-
store->computeFSClosure(store->parseStorePath(STRING_VIEW(path)), path_set,
154-
flip_direction, include_outputs);
155-
}
156-
return extract_path_set(path_set);
157-
}
158-
159-
rust::Vec<rust::String> topo_sort_paths(rust::Vec<rust::Str> paths) {
160-
auto store = get_store();
161-
nix::StorePathSet path_set;
162-
for (auto &path : paths) {
163-
path_set.insert(store->parseStorePath(STRING_VIEW(path)));
164-
}
165-
nix::StorePaths sorted = store->topoSortPaths(path_set);
166-
rust::Vec<rust::String> res;
167-
res.reserve(sorted.size());
168-
for (auto &path : sorted) {
169-
res.push_back(store->printStorePath(path));
170-
}
171-
return res;
172-
}
173-
174-
rust::String follow_links_to_store_path(rust::Str path) {
175-
auto store = get_store();
176-
return store->printStorePath(
177-
store->followLinksToStorePath(STRING_VIEW(path)));
178-
}
179-
180-
void export_paths(int32_t fd, rust::Vec<rust::Str> paths) {
181-
auto store = get_store();
182-
nix::StorePathSet path_set;
183-
for (auto &path : paths) {
184-
path_set.insert(store->parseStorePath(STRING_VIEW(path)));
185-
}
186-
nix::FdSink sink(fd);
187-
store->exportPaths(path_set, sink);
188-
}
189-
190-
void import_paths(int32_t fd, bool dont_check_signs) {
191-
nix::FdSource source(fd);
192-
get_store()->importPaths(source, dont_check_signs ? nix::NoCheckSigs
193-
: nix::CheckSigs);
194-
}
195-
196-
rust::String hash_file(rust::Str algo, bool base32, rust::Str path) {
197-
nix::Hash h =
198-
nix::hashFile(nix::parseHashAlgo(STRING_VIEW(algo)), STRING_VIEW(path));
199-
return h.to_string(base32 ? nix::HashFormat::Nix32 : nix::HashFormat::Base16,
200-
false);
201-
}
202-
203-
rust::String hash_string(rust::Str algo, bool base32, rust::Str s) {
204-
nix::Hash h =
205-
nix::hashString(nix::parseHashAlgo(STRING_VIEW(algo)), STRING_VIEW(s));
206-
return h.to_string(base32 ? nix::HashFormat::Nix32 : nix::HashFormat::Base16,
207-
false);
208-
}
209-
210129
rust::String convert_hash(rust::Str algo, rust::Str s, bool to_base_32) {
211130
nix::Hash h = nix::Hash::parseAny(STRING_VIEW(s),
212131
nix::parseHashAlgo(STRING_VIEW(algo)));
@@ -269,15 +188,6 @@ InternalDrv derivation_from_path(rust::Str drv_path) {
269188
};
270189
}
271190

272-
void add_temp_root(rust::Str store_path) {
273-
auto store = get_store();
274-
store->addTempRoot(store->parseStorePath(STRING_VIEW(store_path)));
275-
}
276-
277-
rust::String get_bin_dir() {
278-
return nix::settings.nixBinDir;
279-
}
280-
281191
rust::String get_store_dir() {
282192
return nix::settings.nixStore;
283193
}

0 commit comments

Comments
 (0)