8000 rust: remove dependency on rustc by figsoda · Pull Request #797 · nix-community/nix-init · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/lang/rust/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub async fn load_cargo_lock(
.map_err(anyhow::Error::from)
.and_then(|mut target| {
let cfg = cargo_config(src_dir)?;
let ws = Workspace::new(&src_dir.join("Cargo.toml"), &cfg)?;
let ws = cargo_workspace(src_dir, &cfg)?;
let resolve = resolve_with_previous(
&mut PackageRegistry::new_with_source_config(
&cfg,
Expand Down Expand Up @@ -187,7 +187,7 @@ fn resolve_workspace(src_dir: &Path) -> Option<Resolve> {
cfg.configure(0, false, None, false, true, false, &None, &[], &[])
.ok_inspect(|e| error!("{e}"))?;

let ws = Workspace::new(&src_dir.join("Cargo.toml"), &cfg).ok_inspect(|e| error!("{e}"))?;
let ws = cargo_workspace(src_dir, &cfg).ok_inspect(|e| error!("{e}"))?;
let lock = load_pkg_lockfile(&ws).ok_inspect(|e| error!("{e}"))?;

let mut registry =
Expand Down Expand Up @@ -215,6 +215,13 @@ fn cargo_config(src_dir: &Path) -> Result<GlobalContext> {
))
}

fn cargo_workspace<'a>(src_dir: &Path, cfg: &'a GlobalContext) -> Result<Workspace<'a>> {
let mut ws = Workspace::new(&src_dir.join("Cargo.toml"), cfg)?;
// avoid dependency on rustc
ws.set_resolve_honors_rust_version(Some(false));
Ok(ws)
}

fn load_rust_dependencies(inputs: &mut AllInputs, resolve: &Resolve) {
for pkg in resolve.iter() {
load_rust_dependency(inputs, resolve, pkg);
Expand Down
0