diff options
author | Vova Kryachko <v.kryachko@gmail.com> | 2024-11-12T17·30-0500 |
---|---|---|
committer | Vladimir Kryachko <v.kryachko@gmail.com> | 2024-11-14T13·39+0000 |
commit | ccecede70b28523cdb26a78dab23c357032cf96d (patch) | |
tree | 1a9f1679b576353c00c1f71989a802a4292a9e84 /tvix/nix-compat/src/nix_daemon/handler.rs | |
parent | fa9c067dc9b631363659b55053f5f6d4428eb8a4 (diff) |
feat(nix-daemon): Implement stubs for QueryReferrers, QueryRealizations r/8918
These are required to support certain nix's local-overlay store operations, it's safer to return empty results for these operations than failing with "operation not implemented" errors. Change-Id: Ic9b69d75dd52af5a826bfb6a8b283b082a0f6bcf Reviewed-on: https://cl.tvl.fyi/c/depot/+/12766 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/nix-compat/src/nix_daemon/handler.rs')
-rw-r--r-- | tvix/nix-compat/src/nix_daemon/handler.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tvix/nix-compat/src/nix_daemon/handler.rs b/tvix/nix-compat/src/nix_daemon/handler.rs index a61a4810c807..65c5c2d60d08 100644 --- a/tvix/nix-compat/src/nix_daemon/handler.rs +++ b/tvix/nix-compat/src/nix_daemon/handler.rs @@ -5,7 +5,7 @@ use tokio::{ io::{split, AsyncReadExt, AsyncWriteExt, ReadHalf, WriteHalf}, sync::Mutex, }; -use tracing::debug; +use tracing::{debug, warn}; use super::{ types::QueryValidPaths, @@ -146,6 +146,23 @@ where let path: StorePath<String> = self.reader.read_value().await?; self.handle(io.query_valid_derivers(&path)).await? } + // FUTUREWORK: These are just stubs that return an empty list. + // It's important not to return an error for the local-overlay:// store + // to work properly. While it will not see certain referrers and realizations + // it will not fail on various operations like gc and optimize store. At the + // same time, returning an empty list here shouldn't break any of local-overlay store's + // invariants. + Operation::QueryReferrers | Operation::QueryRealisation => { + let _: String = self.reader.read_value().await?; + self.handle(async move { + warn!( + ?operation, + "This operation is not implemented. Returning empty result..." + ); + Ok(Vec::<StorePath<String>>::new()) + }) + .await? + } _ => { return Err(std::io::Error::other(format!( "Operation {operation:?} is not implemented" |