--- a/crates/fleet-base/src/opts.rs
+++ b/crates/fleet-base/src/opts.rs
@@ -8,7 +8,7 @@
use anyhow::Result;
use clap::Parser;
-use nix_eval::{nix_go, nix_go_json, util::assert_warn, NixSessionPool, Value};
+use nix_eval::{nix_go, util::assert_warn, NixSessionPool, Value};
use nom::{
bytes::complete::take_while1,
character::complete::char,
@@ -85,14 +85,16 @@
/// Override detected system for host, to perform builds via
/// binfmt-declared qemu instead of trying to crosscompile
- // TODO: Remove, as it is not used anymore.
- #[clap(long, default_value = "detect")]
+ #[clap(long, default_value = env!("NIX_SYSTEM"))]
pub local_system: String,
}
impl FleetOpts {
- pub async fn filter_skipped(&self, hosts: impl IntoIterator<Item = ConfigHost>) -> Result<Vec<ConfigHost>> {
- let mut out = Vec::new();
+ pub async fn filter_skipped(
+ &self,
+ hosts: impl IntoIterator<Item = ConfigHost>,
+ ) -> Result<Vec<ConfigHost>> {
+ let mut out = Vec::new();
for host in hosts {
if self.should_skip(&host).await? {
continue;
@@ -182,15 +184,15 @@
pub async fn build(&self, nix_args: Vec<OsString>) -> Result<Config> {
let directory = current_dir()?;
- let pool = NixSessionPool::new(directory.as_os_str().to_owned(), nix_args.clone()).await?;
+ let pool = NixSessionPool::new(
+ directory.as_os_str().to_owned(),
+ nix_args.clone(),
+ self.local_system.clone(),
+ )
+ .await?;
let nix_session = pool.get().await?;
let builtins_field = Value::binding(nix_session.clone(), "builtins").await?;
- let local_system = if self.local_system == "detect" {
- nix_go_json!(builtins_field.currentSystem)
- } else {
- self.local_system.clone()
- };
let mut fleet_data_path = directory.clone();
fleet_data_path.push("fleet.nix");
@@ -210,14 +212,14 @@
let default_pkgs = nix_go!(nixpkgs(Obj {
overlays,
- system: local_system.clone(),
+ system: self.local_system.clone(),
}));
Ok(Config(Arc::new(FleetConfigInternals {
nix_session,
directory,
data,
- local_system,
+ local_system: self.local_system.clone(),
nix_args,
config_field,
default_pkgs,
--- a/crates/nix-eval/src/lib.rs
+++ b/crates/nix-eval/src/lib.rs
@@ -41,8 +41,8 @@
#[instrument(skip(session, values))]
async fn build_multiple(name: String, session: NixSession, values: Vec<Value>) -> Result<()> {
+ let system = session.0.lock().await.nix_system.clone();
let builtins = Value::binding(session, "builtins").await?;
- let system = nix_go!(builtins.currentSystem);
let drv = nix_go!(builtins.derivation(Obj {
system,
name,
--- a/crates/nix-eval/src/session.rs
+++ b/crates/nix-eval/src/session.rs
@@ -206,6 +206,8 @@
next_id: u32,
pub(crate) free_list: Vec<u32>,
+
+ pub nix_system: String,
}
/// Discover inter-message repl delimiter
@@ -222,6 +224,7 @@
pub(crate) async fn new(
flake: &OsStr,
extra_args: impl IntoIterator<Item = &OsStr>,
+ nix_system: String,
) -> Result<Self> {
let mut cmd = Command::new("nix");
cmd.arg("repl")
@@ -280,6 +283,8 @@
next_id: 0,
free_list: vec![],
+
+ nix_system,
};
res.train().await?;
Ok(res)