refactor(tvix): introduce nix-compat crate
Move nixbase32 and store_path into this. This allows //tvix/cli to not pull in //tvix/store for now. Change-Id: Id3a32867205d95794bc0d33b21d4cb3d9bafd02a Reviewed-on: https://cl.tvl.fyi/c/depot/+/7964 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
parent
8ea93bb646
commit
c27bacd905
20 changed files with 109 additions and 27 deletions
16
tvix/Cargo.lock
generated
16
tvix/Cargo.lock
generated
|
@ -1301,6 +1301,18 @@ dependencies = [
|
|||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix-compat"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"data-encoding",
|
||||
"glob",
|
||||
"sha2 0.10.6",
|
||||
"test-case",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom8"
|
||||
version = "0.2.0"
|
||||
|
@ -2617,7 +2629,6 @@ dependencies = [
|
|||
"thiserror",
|
||||
"tvix-derivation",
|
||||
"tvix-eval",
|
||||
"tvix-store-bin",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2627,13 +2638,13 @@ dependencies = [
|
|||
"anyhow",
|
||||
"data-encoding",
|
||||
"glob",
|
||||
"nix-compat",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2 0.10.6",
|
||||
"test-case",
|
||||
"test-generator",
|
||||
"thiserror",
|
||||
"tvix-store-bin",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2699,6 +2710,7 @@ dependencies = [
|
|||
"data-encoding",
|
||||
"fastcdc",
|
||||
"lazy_static",
|
||||
"nix-compat",
|
||||
"prost",
|
||||
"prost-build",
|
||||
"sled",
|
||||
|
|
|
@ -43,6 +43,16 @@ rec {
|
|||
# File a bug if you depend on any for non-debug work!
|
||||
debug = internal.debugCrate { inherit packageId; };
|
||||
};
|
||||
"nix-compat" = rec {
|
||||
packageId = "nix-compat";
|
||||
build = internal.buildRustCrateWithFeatures {
|
||||
packageId = "nix-compat";
|
||||
};
|
||||
|
||||
# Debug support which might change between releases.
|
||||
# File a bug if you depend on any for non-debug work!
|
||||
debug = internal.debugCrate { inherit packageId; };
|
||||
};
|
||||
"tvix-cli" = rec {
|
||||
packageId = "tvix-cli";
|
||||
build = internal.buildRustCrateWithFeatures {
|
||||
|
@ -3725,6 +3735,46 @@ rec {
|
|||
features = { };
|
||||
resolvedDefaultFeatures = [ "integration_tests" ];
|
||||
};
|
||||
"nix-compat" = rec {
|
||||
crateName = "nix-compat";
|
||||
version = "0.1.0";
|
||||
edition = "2021";
|
||||
# We can't filter paths with references in Nix 2.4
|
||||
# See https://github.com/NixOS/nix/issues/5410
|
||||
src =
|
||||
if (lib.versionOlder builtins.nixVersion "2.4pre20211007")
|
||||
then lib.cleanSourceWith { filter = sourceFilter; src = ./nix-compat; }
|
||||
else ./nix-compat;
|
||||
dependencies = [
|
||||
{
|
||||
name = "anyhow";
|
||||
packageId = "anyhow";
|
||||
}
|
||||
{
|
||||
name = "data-encoding";
|
||||
packageId = "data-encoding";
|
||||
}
|
||||
{
|
||||
name = "glob";
|
||||
packageId = "glob";
|
||||
}
|
||||
{
|
||||
name = "sha2";
|
||||
packageId = "sha2 0.10.6";
|
||||
}
|
||||
{
|
||||
name = "thiserror";
|
||||
packageId = "thiserror";
|
||||
}
|
||||
];
|
||||
devDependencies = [
|
||||
{
|
||||
name = "test-case";
|
||||
packageId = "test-case";
|
||||
}
|
||||
];
|
||||
|
||||
};
|
||||
"nom8" = rec {
|
||||
crateName = "nom8";
|
||||
version = "0.2.0";
|
||||
|
@ -7745,10 +7795,6 @@ rec {
|
|||
name = "tvix-eval";
|
||||
packageId = "tvix-eval";
|
||||
}
|
||||
{
|
||||
name = "tvix-store-bin";
|
||||
packageId = "tvix-store-bin";
|
||||
}
|
||||
];
|
||||
|
||||
};
|
||||
|
@ -7775,6 +7821,10 @@ rec {
|
|||
name = "glob";
|
||||
packageId = "glob";
|
||||
}
|
||||
{
|
||||
name = "nix-compat";
|
||||
packageId = "nix-compat";
|
||||
}
|
||||
{
|
||||
name = "serde";
|
||||
packageId = "serde";
|
||||
|
@ -7788,10 +7838,6 @@ rec {
|
|||
name = "thiserror";
|
||||
packageId = "thiserror";
|
||||
}
|
||||
{
|
||||
name = "tvix-store-bin";
|
||||
packageId = "tvix-store-bin";
|
||||
}
|
||||
];
|
||||
devDependencies = [
|
||||
{
|
||||
|
@ -8060,6 +8106,10 @@ rec {
|
|||
name = "lazy_static";
|
||||
packageId = "lazy_static";
|
||||
}
|
||||
{
|
||||
name = "nix-compat";
|
||||
packageId = "nix-compat";
|
||||
}
|
||||
{
|
||||
name = "prost";
|
||||
packageId = "prost";
|
||||
|
|
|
@ -24,6 +24,7 @@ members = [
|
|||
"eval/builtin-macros",
|
||||
"nar",
|
||||
"nix_cli",
|
||||
"nix-compat",
|
||||
"serde",
|
||||
"store",
|
||||
]
|
||||
|
|
|
@ -12,7 +12,6 @@ tvix-eval = { path = "../eval" }
|
|||
tvix-derivation = { path = "../derivation" }
|
||||
rustyline = "10.0.0"
|
||||
clap = { version = "4.0", features = ["derive", "env"] }
|
||||
tvix-store-bin = { path = "../store" }
|
||||
dirs = "4.0.0"
|
||||
smol_str = "0.1"
|
||||
aho-corasick = "0.7"
|
||||
|
|
|
@ -9,10 +9,10 @@ edition = "2021"
|
|||
anyhow = "1.0.68"
|
||||
data-encoding = "2.3.3"
|
||||
glob = "0.3.0"
|
||||
nix-compat = { path = "../nix-compat" }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
sha2 = "0.10.6"
|
||||
thiserror = "1.0.38"
|
||||
tvix-store-bin = { path = "../store" }
|
||||
|
||||
[dev-dependencies.test-generator]
|
||||
# This fork of test-generator adds support for cargo workspaces, see
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use crate::output::{Hash, Output};
|
||||
use crate::write;
|
||||
use crate::DerivationError;
|
||||
use nix_compat::nixbase32;
|
||||
use nix_compat::store_path::{StorePath, STORE_DIR};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::collections::BTreeSet;
|
||||
use std::{collections::BTreeMap, fmt, fmt::Write};
|
||||
use tvix_store::nixbase32;
|
||||
use tvix_store::store_path::{StorePath, STORE_DIR};
|
||||
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Derivation {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use nix_compat::{nixbase32::Nixbase32DecodeError, store_path::ParseStorePathError};
|
||||
use thiserror::Error;
|
||||
use tvix_store::{nixbase32::Nixbase32DecodeError, store_path::ParseStorePathError};
|
||||
|
||||
/// Errors that can occur during the validation of Derivation structs.
|
||||
#[derive(Debug, Error, PartialEq)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use nix_compat::{nixbase32, store_path::StorePath};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tvix_store::{nixbase32, store_path::StorePath};
|
||||
|
||||
use crate::OutputError;
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use crate::derivation::Derivation;
|
||||
use crate::output::{Hash, Output};
|
||||
use nix_compat::store_path::StorePath;
|
||||
use std::collections::BTreeSet;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::path::Path;
|
||||
use test_case::test_case;
|
||||
use test_generator::test_resources;
|
||||
use tvix_store::store_path::StorePath;
|
||||
|
||||
const RESOURCES_PATHS: &str = "src/tests/derivation_tests";
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{derivation::Derivation, DerivationError};
|
||||
use tvix_store::store_path::StorePath;
|
||||
use nix_compat::store_path::StorePath;
|
||||
|
||||
impl Derivation {
|
||||
/// validate ensures a Derivation struct is properly populated,
|
||||
|
|
16
tvix/nix-compat/Cargo.toml
Normal file
16
tvix/nix-compat/Cargo.toml
Normal file
|
@ -0,0 +1,16 @@
|
|||
[package]
|
||||
name = "nix-compat"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.68"
|
||||
data-encoding = "2.3.3"
|
||||
glob = "0.3.0"
|
||||
sha2 = "0.10.6"
|
||||
thiserror = "1.0.38"
|
||||
|
||||
[dev-dependencies]
|
||||
test-case = "2.2.2"
|
5
tvix/nix-compat/default.nix
Normal file
5
tvix/nix-compat/default.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
{ depot, ... }:
|
||||
|
||||
depot.tvix.crates.workspaceMembers.nix-compat.build.override {
|
||||
runTests = true;
|
||||
}
|
2
tvix/nix-compat/src/lib.rs
Normal file
2
tvix/nix-compat/src/lib.rs
Normal file
|
@ -0,0 +1,2 @@
|
|||
pub mod nixbase32;
|
||||
pub mod store_path;
|
|
@ -14,9 +14,10 @@ lazy_static = "1.4.0"
|
|||
clap = { version = "4.0", features = ["derive", "env"] }
|
||||
prost = "0.11.2"
|
||||
sled = { version = "0.34.7", features = ["compression"] }
|
||||
nix-compat = { path = "../nix-compat" }
|
||||
thiserror = "1.0.38"
|
||||
tokio = { version = "1.23.0", features = ["rt-multi-thread"] }
|
||||
tokio-stream = "0.1.11"
|
||||
tokio = { version = "1.23.0", features = ["rt-multi-thread"] }
|
||||
tonic = "0.8.2"
|
||||
tracing-subscriber = "0.3.16"
|
||||
tracing = "0.1.37"
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
pub mod nixbase32;
|
||||
pub mod proto;
|
||||
pub mod store_path;
|
||||
|
||||
pub mod dummy_blob_service;
|
||||
pub mod sled_directory_service;
|
||||
|
|
|
@ -5,7 +5,7 @@ use thiserror::Error;
|
|||
|
||||
use prost::Message;
|
||||
|
||||
use crate::store_path::{ParseStorePathError, StorePath};
|
||||
use nix_compat::store_path::{ParseStorePathError, StorePath};
|
||||
|
||||
tonic::include_proto!("tvix.store.v1");
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::proto::CalculateNarResponse;
|
|||
use crate::proto::GetPathInfoRequest;
|
||||
use crate::proto::Node;
|
||||
use crate::proto::PathInfo;
|
||||
use crate::store_path::DIGEST_SIZE;
|
||||
use nix_compat::store_path::DIGEST_SIZE;
|
||||
use tonic::{Request, Response, Result, Status};
|
||||
use tracing::{instrument, warn};
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use crate::{
|
||||
proto::{self, Node, PathInfo, ValidatePathInfoError},
|
||||
store_path::{ParseStorePathError, StorePath},
|
||||
};
|
||||
use crate::proto::{self, Node, PathInfo, ValidatePathInfoError};
|
||||
use lazy_static::lazy_static;
|
||||
use nix_compat::store_path::{ParseStorePathError, StorePath};
|
||||
use test_case::test_case;
|
||||
|
||||
lazy_static! {
|
||||
|
|
Loading…
Reference in a new issue