Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 0 additions & 136 deletions src/cli/subcommand/install/determinate.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,7 @@
use std::io::IsTerminal as _;

use owo_colors::OwoColorize as _;

use crate::cli::interaction::PromptChoice;
use crate::feedback::Feedback;
use crate::planner::BuiltinPlanner;

const PRE_PKG_SUGGEST: &str = "For a more robust Nix installation, use the Determinate package for macOS: https://dtr.mn/determinate-nix";

const INSTALL_DETERMINATE_NIX_PROMPT: &str = "\
Install Determinate Nix?

It has stable flakes, lazy trees, parallel evaluation, and more.

Selecting 'no' will install upstream Nix, which comes from NixOS.org.\
";

const DETERMINATE_MSG_EXPLAINER: &str = "\
Determinate Nix is Determinate Systems' validated and secure downstream Nix distribution for enterprises. \
It is the direct result of our work to ship meaningful user experience and reliability improvements to Nix.
It comes bundled with Determinate Nixd, a helpful daemon that automates some otherwise-unpleasant aspects of using Nix, such as garbage collection, and enables you to easily authenticate with FlakeHub.

For more details: https://dtr.mn/determinate-nix\
";

pub(crate) async fn inform_macos_about_pkg<T: Feedback>(feedback: &T) {
if matches!(
target_lexicon::OperatingSystem::host(),
Expand All @@ -36,117 +14,3 @@ pub(crate) async fn inform_macos_about_pkg<T: Feedback>(feedback: &T) {
tracing::info!("{}", msg.trim());
}
}

pub(crate) async fn prompt_for_determinate<T: Feedback>(
feedback: &mut T,
planner: &mut BuiltinPlanner,
no_confirm: bool,
) -> eyre::Result<Option<String>> {
let planner_settings = planner.common_settings_mut();

if !planner_settings.determinate_nix {
// This is deliberately checking the determinate_nix option, and not `.distribution()`.
// When we default to Determinate Nix on November 10, we'll change prefer_upstream's default to false.
// Then, .distribution() will be Determinate Nix, but .determinate_nix will still be false.
// That means we'll still show this warning.

eprintln!();
eprintln!(
"{} The Determinate Nix Installer will stop distributing upstream Nix no sooner than {}.",
"Important:".bold().red().italic(),
"January 1, 2026".italic()
);

eprintln!("\n{}", "Timeline".bold().underline());

eprintln!(
"* {}: we are changing the installer to default to Determinate Nix.",
"November 10".bold()
);
eprintln!(
" You can add the `{}` flag now to keep upstream Nix as the default.",
"--prefer-upstream-nix".italic()
);
eprintln!(
"* {}: we are removing support for installing upstream Nix.",
"January 1".bold()
);
eprintln!(
" The `{}` flag will not have an effect any longer.",
"--prefer-upstream-nix".italic()
);

eprintln!(
"\nThe DeterminateSystems/nix-installer-action GitHub Action is also affected.\n"
);
eprintln!(
"{} https://determinate.systems/blog/installer-dropping-upstream/",
"Details:".bold().italic()
);
}

if planner_settings.distribution().is_upstream()
&& std::io::stdin().is_terminal()
&& !no_confirm
{
let base_prompt = feedback
.get_feature_ptr_payload::<String>("dni-det-msg-interactive-prompt-ptr")
.await
.unwrap_or(INSTALL_DETERMINATE_NIX_PROMPT.into());

let mut explanation: Option<String> = None;

loop {
let prompt = if let Some(ref explanation) = explanation {
&format!("\n{}\n{}", base_prompt.trim().green(), explanation.trim())
} else {
&format!("\n{}", base_prompt.trim().green())
};

let response = crate::cli::interaction::prompt(
prompt.to_string(),
PromptChoice::Yes,
explanation.is_some(),
)
.await?;

match response {
PromptChoice::Explain => {
explanation = Some(
feedback
.get_feature_ptr_payload::<String>(
"dni-det-msg-interactive-explanation-ptr",
)
.await
.unwrap_or(DETERMINATE_MSG_EXPLAINER.into()),
);
},
PromptChoice::Yes => {
planner_settings.determinate_nix = true;
break;
},
PromptChoice::No => {
break;
},
}
}
}

let post_install_message_feature = match (
planner_settings.distribution().is_determinate(),
std::io::stdin().is_terminal() && !no_confirm,
) {
(true, true) => Some("dni-post-det-int-ptr"),
(true, false) => None,
(false, true) => Some("dni-post-ups-int-ptr"),
(false, false) => Some("dni-post-ups-scr-ptr"),
};

let msg = if let Some(feat) = post_install_message_feature {
feedback.get_feature_ptr_payload::<String>(feat).await
} else {
None
};

Ok(msg)
}
12 changes: 1 addition & 11 deletions src/cli/subcommand/install/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,13 @@ impl CommandExecute for Install {

determinate::inform_macos_about_pkg(&feedback).await;

let mut post_install_message = None;

let mut install_plan = if let Some(plan_path) = plan {
let install_plan_string = tokio::fs::read_to_string(&plan_path)
.await
.wrap_err("Reading plan")?;
serde_json::from_str(&install_plan_string)?
} else {
let mut planner = match maybe_planner {
let planner = match maybe_planner {
Some(planner) => planner,
None => BuiltinPlanner::from_common_settings(settings.clone())
.await
Expand Down Expand Up @@ -162,10 +160,6 @@ impl CommandExecute for Install {
return Ok(ExitCode::SUCCESS);
}

post_install_message =
determinate::prompt_for_determinate(&mut feedback, &mut planner, no_confirm)
.await?;

feedback.set_planner(&planner).await?;

let res = planner.plan().await;
Expand Down Expand Up @@ -344,10 +338,6 @@ impl CommandExecute for Install {
". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh".bold(),
},
);

if let Some(msg) = post_install_message {
println!("{}\n", msg.trim());
}
},
}

Expand Down
4 changes: 2 additions & 2 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct CommonSettings {
long = "prefer-upstream-nix",
env = "NIX_INSTALLER_PREFER_UPSTREAM_NIX",
// Note this default is replicated in a default() implementation
default_value = "true"
default_value = "false"
)
)]
pub prefer_upstream: bool,
Expand Down Expand Up @@ -240,7 +240,7 @@ impl CommonSettings {

Ok(Self {
determinate_nix: false,
prefer_upstream: true,
prefer_upstream: false,
modify_profile: true,
nix_build_group_name: String::from(crate::settings::DEFAULT_NIX_BUILD_USER_GROUP_NAME),
nix_build_group_id: default_nix_build_group_id(),
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/linux/linux.json
Original file line number Diff line number Diff line change
Expand Up @@ -1144,8 +1144,8 @@
"planner": {
"planner": "linux",
"settings": {
"determinate_nix": false,
"prefer_upstream": true,
"determinate_nix": true,
"prefer_upstream": false,
"modify_profile": true,
"nix_build_group_name": "nixbld",
"nix_build_group_id": 30000,
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/linux/steam-deck.json
Original file line number Diff line number Diff line change
Expand Up @@ -1172,8 +1172,8 @@
"planner": "steam-deck",
"persistence": "/home/nix",
"settings": {
"determinate_nix": false,
"prefer_upstream": true,
"determinate_nix": true,
"prefer_upstream": false,
"modify_profile": true,
"nix_build_group_name": "nixbld",
"nix_build_group_id": 30000,
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/macos/macos.json
Original file line number Diff line number Diff line change
Expand Up @@ -1244,8 +1244,8 @@
"planner": {
"planner": "macos",
"settings": {
"determinate_nix": false,
"prefer_upstream": true,
"determinate_nix": true,
"prefer_upstream": false,
"modify_profile": true,
"nix_build_group_name": "nixbld",
"nix_build_group_id": 350,
Expand Down
Loading