Commit 246199e4 authored by K900's avatar K900
Browse files

buildFHSEnv: skip other fhsenvs for includeClosures

parent 3f94560d
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@ struct PriorityKey {
    root_index: usize,
}

const FHSENV_MARKER_FILE: &str = "nix-support/is-fhsenv";

fn build_reference_map(refs: Vec<RefGraphNode>) -> HashMap<PathBuf, Vec<PathBuf>> {
    refs.into_iter()
        .map(|mut gn| {
@@ -119,6 +121,11 @@ fn collect_candidate_paths(
    let mut candidates: HashMap<_, Vec<_>> = HashMap::new();

    for (path, priority) in paths {
        if path.join(FHSENV_MARKER_FILE).exists() {
            // is another fhsenv, skip it
            continue;
        }

        for entry in WalkDir::new(&path).follow_links(true) {
            let entry: PathBuf = match entry {
                Ok(ent) => {
@@ -264,6 +271,14 @@ fn build_env(out: &Path, plan: HashMap<PathBuf, PathBuf>) -> anyhow::Result<()>
            .with_context(|| format!("When symlinking {src:?} to {full_dest:?}"))?;
    }

    let marker = out.join(FHSENV_MARKER_FILE);
    fs::create_dir_all(
        marker
            .parent()
            .ok_or(anyhow!("marker file is in root, this should never happen"))?,
    )?;
    fs::write(marker, [])?;

    Ok(())
}