use std::env; use std::process::Command; fn main() { const FILE: &str = "demo/linalg/src/lib.rs"; println!("cargo:rerun-if-changed={FILE}"); let current_dir = env::current_dir().unwrap(); let linalg_dir = current_dir.join("demo").join("linalg"); env::set_current_dir(&linalg_dir).unwrap(); let output = Command::new("nix-build").current_dir(&linalg_dir).output().unwrap(); if !output.status.success() { let stderr = String::from_utf8_lossy(&output.stderr); eprintln!("nix-build failed: {}", stderr); std::process::exit(1); } env::set_current_dir(current_dir).unwrap(); }