From 741d5c4fbbd6cf273c330baa6c035263e76a1071 Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Wed, 17 Aug 2022 11:56:30 -0600 Subject: [PATCH] repl: Use a temporary file for the expression This makes it compatible with Nix 2.3+. --- src/command/repl.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/command/repl.rs b/src/command/repl.rs index c0c827e..b2c5436 100644 --- a/src/command/repl.rs +++ b/src/command/repl.rs @@ -1,4 +1,7 @@ +use std::io::Write; + use clap::{ArgMatches, Command as ClapCommand}; +use tempfile::Builder as TempFileBuilder; use tokio::process::Command; use crate::error::ColmenaError; @@ -21,12 +24,19 @@ pub async fn run(_global_args: &ArgMatches, local_args: &ArgMatches) -> Result<( let expr = hive.get_repl_expression(); + let mut expr_file = TempFileBuilder::new() + .prefix("colmena-repl-") + .suffix(".nix") + .tempfile()?; + + expr_file.write_all(expr.as_bytes())?; + let status = Command::new("nix") .arg("repl") // `nix repl` is expected to be marked as experimental: // .args(&["--experimental-features", "nix-command flakes"]) - .args(&["--expr", &expr]) + .arg(expr_file.path()) .status() .await?;