diff --git a/crate2nix/src/config.rs b/crate2nix/src/config.rs index b20e3768..09ae0ef4 100644 --- a/crate2nix/src/config.rs +++ b/crate2nix/src/config.rs @@ -7,7 +7,7 @@ use std::{ fmt::Display, fs::File, io::{BufReader, BufWriter}, - path::Path, + path::{Path, PathBuf}, str::FromStr, }; @@ -116,6 +116,11 @@ pub enum Source { #[serde(skip_serializing_if = "Option::is_none")] attr: Option, }, + /// The source is already obtained, useful for IFD. + LocalDirectory { + /// Path to the source. + path: PathBuf, + }, } /// A nix file path which is either included by `import` or `callPackage`. @@ -187,6 +192,7 @@ impl Display for Source { file, attr: Some(attr), } => write!(f, "({}).{}", file, attr), + Source::LocalDirectory { path } => write!(f, "{}", path.display()), } } } @@ -210,6 +216,9 @@ impl Source { file, attr: Some(attr), } => format!("nix --name '{}' {} '{}'", name, file.as_command(), attr), + Source::LocalDirectory { path } => { + format!("path --name '{}' {}", name, path.display()) + }, } } } diff --git a/crate2nix/src/resolve.rs b/crate2nix/src/resolve.rs index e8ff2c41..ef21aa6e 100644 --- a/crate2nix/src/resolve.rs +++ b/crate2nix/src/resolve.rs @@ -384,6 +384,9 @@ impl From for ResolvedSource { crate::config::Source::Nix { file, attr } => { ResolvedSource::Nix(NixSource { file, attr }) } + crate::config::Source::LocalDirectory { path } => { + ResolvedSource::LocalDirectory(LocalDirectorySource { path }) + } } } }