1use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum NixError {
8 #[error("Nix is not installed or not in PATH")]
10 NixNotFound,
11
12 #[error("Nix command failed: {0}")]
14 NixCommandFailed(String),
15
16 #[error("Flake not found at path: {0}")]
18 FlakeNotFound(String),
19
20 #[error("Invalid flake.lock format: {0}")]
22 InvalidFlakeLock(String),
23
24 #[error("Attic is not configured")]
26 AtticNotConfigured,
27
28 #[error("Attic command failed: {0}")]
30 AtticCommandFailed(String),
31
32 #[error("Environment not found in cache: {0}")]
34 EnvironmentNotCached(String),
35
36 #[error("IO error: {0}")]
38 Io(#[from] std::io::Error),
39
40 #[error("JSON parsing error: {0}")]
42 Json(#[from] serde_json::Error),
43
44 #[error("HTTP error: {0}")]
46 Http(String),
47
48 #[error("Hash computation failed: {0}")]
50 HashError(String),
51}
52
53impl From<reqwest::Error> for NixError {
54 fn from(err: reqwest::Error) -> Self {
55 NixError::Http(err.to_string())
56 }
57}