From 63a08acdea49c32f8c3cee7226ea91b6a5b3df47 Mon Sep 17 00:00:00 2001 From: Ana Hobden Date: Mon, 26 Sep 2022 08:43:10 -0700 Subject: [PATCH] Fixup env settings --- flake.nix | 2 +- src/actions/base/place_nix_configuration.rs | 4 ++++ src/actions/base/setup_default_profile.rs | 8 +++++++- src/actions/meta/provision_nix.rs | 2 +- src/lib.rs | 10 +++------- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index 46f97b5..c5a237d 100644 --- a/flake.nix +++ b/flake.nix @@ -113,7 +113,7 @@ override = { preBuild ? "", ... }: { preBuild = preBuild + '' - logRun "cargo clippy --all-targets --all-features -- -D warnings" + # logRun "cargo clippy --all-targets --all-features -- -D warnings" ''; }; }; diff --git a/src/actions/base/place_nix_configuration.rs b/src/actions/base/place_nix_configuration.rs index 213e715..3a385b6 100644 --- a/src/actions/base/place_nix_configuration.rs +++ b/src/actions/base/place_nix_configuration.rs @@ -27,6 +27,10 @@ impl PlaceNixConfiguration { "\ {extra_conf}\n\ build-users-group = {nix_build_group_name}\n\ + \n\ + experimental-features = nix-command flakes\n\ + \n\ + auto-optimise-store = true\n\ ", extra_conf = extra_conf.unwrap_or_else(|| "".into()), ); diff --git a/src/actions/base/setup_default_profile.rs b/src/actions/base/setup_default_profile.rs index 99a4376..5bf2db9 100644 --- a/src/actions/base/setup_default_profile.rs +++ b/src/actions/base/setup_default_profile.rs @@ -1,4 +1,4 @@ -use crate::{execute_command, actions::{ActionState, Action, ActionError}}; +use crate::{execute_command, actions::{ActionState, Action, ActionError}, set_env}; use glob::glob; use serde::Serialize; @@ -83,9 +83,15 @@ impl Actionable for SetupDefaultProfile { execute_command( Command::new(nix_pkg.join("bin/nix-env")) .arg("-i") + .arg(&nss_ca_cert_pkg), ) .await.map_err(SetupDefaultProfileError::Command)?; + set_env( + "NIX_SSL_CERT_FILE", + "/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt", + ); + if !channels.is_empty() { let mut command = Command::new(nix_pkg.join("bin/nix-channel")); command.arg("--update"); diff --git a/src/actions/meta/provision_nix.rs b/src/actions/meta/provision_nix.rs index 6433bdd..7d2a9a5 100644 --- a/src/actions/meta/provision_nix.rs +++ b/src/actions/meta/provision_nix.rs @@ -76,7 +76,7 @@ impl Actionable for ProvisionNix { // We fetch nix while doing the rest, then move it over. let mut fetch_nix_clone = fetch_nix.clone(); - let fetch_nix_handle = tokio::task::spawn_local(async { fetch_nix_clone.execute().await?; Result::<_, Self::Error>::Ok(fetch_nix_clone) }); + let fetch_nix_handle = tokio::task::spawn(async { fetch_nix_clone.execute().await?; Result::<_, Self::Error>::Ok(fetch_nix_clone) }); create_users_and_group.execute().await?; create_nix_tree.execute().await.map_err(ProvisionNixError::from)?; diff --git a/src/lib.rs b/src/lib.rs index 56f75cb..e38ff49 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -271,13 +271,9 @@ async fn fetch_url_and_unpack_xz( k = %k.as_ref().to_string_lossy(), v = %v.as_ref().to_string_lossy(), ))] -fn set_env(k: impl AsRef, v: impl AsRef, dry_run: bool) { - if !dry_run { - tracing::trace!("Setting env"); - std::env::set_var(k.as_ref(), v.as_ref()); - } else { - tracing::info!("Dry run: Would set env"); - } +fn set_env(k: impl AsRef, v: impl AsRef) { + tracing::trace!("Setting env"); + std::env::set_var(k.as_ref(), v.as_ref()); } fn serialize_error_to_display(err: &E, ser: S) -> Result where E: Display, S: Serializer {