feat: initial nix-daemon implementation

This commit is contained in:
2026-01-17 19:27:59 +08:00
parent 52bf46407a
commit 2ad662c765
28 changed files with 1625 additions and 463 deletions

View File

@@ -104,7 +104,7 @@ fn import_with_complex_dependency_graph() {
// Tests for builtins.path
#[test]
fn test_path_with_file() {
fn path_with_file() {
let mut ctx = Context::new().unwrap();
let temp_dir = tempfile::tempdir().unwrap();
let test_file = temp_dir.path().join("test.txt");
@@ -115,7 +115,7 @@ fn test_path_with_file() {
// Should return a store path string
if let Value::String(store_path) = result {
assert!(store_path.starts_with("/nix/store/"));
assert!(store_path.starts_with(ctx.get_store_dir()));
assert!(store_path.contains("test.txt"));
} else {
panic!("Expected string, got {:?}", result);
@@ -123,7 +123,7 @@ fn test_path_with_file() {
}
#[test]
fn test_path_with_custom_name() {
fn path_with_custom_name() {
let mut ctx = Context::new().unwrap();
let temp_dir = tempfile::tempdir().unwrap();
let test_file = temp_dir.path().join("original.txt");
@@ -144,7 +144,7 @@ fn test_path_with_custom_name() {
}
#[test]
fn test_path_with_directory_recursive() {
fn path_with_directory_recursive() {
let mut ctx = Context::new().unwrap();
let temp_dir = tempfile::tempdir().unwrap();
let test_dir = temp_dir.path().join("mydir");
@@ -159,7 +159,7 @@ fn test_path_with_directory_recursive() {
let result = ctx.eval_code(&expr).unwrap();
if let Value::String(store_path) = result {
assert!(store_path.starts_with("/nix/store/"));
assert!(store_path.starts_with(ctx.get_store_dir()));
assert!(store_path.contains("mydir"));
} else {
panic!("Expected string, got {:?}", result);
@@ -167,7 +167,7 @@ fn test_path_with_directory_recursive() {
}
#[test]
fn test_path_flat_with_file() {
fn path_flat_with_file() {
let mut ctx = Context::new().unwrap();
let temp_dir = tempfile::tempdir().unwrap();
let test_file = temp_dir.path().join("flat.txt");
@@ -180,14 +180,14 @@ fn test_path_flat_with_file() {
let result = ctx.eval_code(&expr).unwrap();
if let Value::String(store_path) = result {
assert!(store_path.starts_with("/nix/store/"));
assert!(store_path.starts_with(ctx.get_store_dir()));
} else {
panic!("Expected string, got {:?}", result);
}
}
#[test]
fn test_path_flat_with_directory_fails() {
fn path_flat_with_directory_fails() {
let mut ctx = Context::new().unwrap();
let temp_dir = tempfile::tempdir().unwrap();
let test_dir = temp_dir.path().join("mydir");
@@ -205,7 +205,7 @@ fn test_path_flat_with_directory_fails() {
}
#[test]
fn test_path_nonexistent_fails() {
fn path_nonexistent_fails() {
let mut ctx = Context::new().unwrap();
let expr = r#"builtins.path { path = "/nonexistent/path/that/should/not/exist"; }"#;
@@ -217,7 +217,7 @@ fn test_path_nonexistent_fails() {
}
#[test]
fn test_path_missing_path_param() {
fn path_missing_path_param() {
let mut ctx = Context::new().unwrap();
let expr = r#"builtins.path { name = "test"; }"#;
@@ -229,7 +229,7 @@ fn test_path_missing_path_param() {
}
#[test]
fn test_path_with_sha256() {
fn path_with_sha256() {
let mut ctx = Context::new().unwrap();
let temp_dir = tempfile::tempdir().unwrap();
let test_file = temp_dir.path().join("hash_test.txt");
@@ -257,7 +257,7 @@ fn test_path_with_sha256() {
}
#[test]
fn test_path_deterministic() {
fn path_deterministic() {
let mut ctx = Context::new().unwrap();
let temp_dir = tempfile::tempdir().unwrap();
let test_file = temp_dir.path().join("deterministic.txt");