Skip to content

Commit

Permalink
Merge pull request #156 from holochain/detect-nix-failure-before-it-h…
Browse files Browse the repository at this point in the history
…appens

Detect Nix failure due to Git conflict
  • Loading branch information
ThetaSinner authored Nov 16, 2023
2 parents 925d041 + 857f584 commit 5ebdb3b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/scaffold/app/nix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,23 @@ pub fn setup_nix_developer_environment(dir: &PathBuf) -> ScaffoldResult<()> {
));
}

// This is here to catch the issue from this thread https://discourse.nixos.org/t/nix-flakes-nix-store-source-no-such-file-or-directory/17836
// If you run Scaffolding inside a Git repository when the `nix flake update` will fail. At some point Nix should report this so we don't need
// to worry about it but for now this helps solve a strange error message.
match Command::new("git")
.stdout(Stdio::piped())
.stderr(Stdio::null())
.current_dir(dir)
.args(["rev-parse", "--is-inside-work-tree"])
.output() {
Ok(output) => {
if output.status.success() && output.stdout == b"true\n" {
return Err(ScaffoldError::NixSetupError("- detected that Scaffolding is running inside an existing Git repository, please choose a different location to scaffold".to_string()));
}
},
Err(_) => {} // Ignore errors, Git isn't necessarily available.
}

println!("Setting up nix development environment...");

add_extra_experimental_features()?;
Expand Down

0 comments on commit 5ebdb3b

Please sign in to comment.