Skip to content

Commit a313ed4

Browse files
committed
Setup channel is add_channel is true
1 parent b28c162 commit a313ed4

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/action/common/configure_nix.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ use crate::{
1111
};
1212
use glob::glob;
1313

14+
use crate::action::common::SetupChannels;
15+
1416
use tracing::{span, Span};
1517

1618
/**
@@ -22,6 +24,7 @@ pub struct ConfigureNix {
2224
setup_default_profile: StatefulAction<SetupDefaultProfile>,
2325
configure_shell_profile: Option<StatefulAction<ConfigureShellProfile>>,
2426
place_nix_configuration: Option<StatefulAction<PlaceNixConfiguration>>,
27+
setup_channels: Option<StatefulAction<SetupChannels>>,
2528
}
2629

2730
impl ConfigureNix {
@@ -60,10 +63,21 @@ impl ConfigureNix {
6063
)
6164
};
6265

66+
let setup_channels = if settings.add_channel {
67+
Some(
68+
SetupChannels::plan(PathBuf::from(SCRATCH_DIR))
69+
.await
70+
.map_err(Self::error)?,
71+
)
72+
} else {
73+
None
74+
};
75+
6376
Ok(Self {
6477
place_nix_configuration,
6578
setup_default_profile,
6679
configure_shell_profile,
80+
setup_channels,
6781
}
6882
.into())
6983
}
@@ -147,12 +161,16 @@ impl Action for ConfigureNix {
147161
setup_default_profile,
148162
place_nix_configuration,
149163
configure_shell_profile,
164+
setup_channels,
150165
} = &self;
151166

152167
let mut buf = setup_default_profile.describe_execute();
153168
if let Some(place_nix_configuration) = place_nix_configuration {
154169
buf.append(&mut place_nix_configuration.describe_execute());
155170
}
171+
if let Some(setup_channels) = setup_channels {
172+
buf.append(&mut setup_channels.describe_execute());
173+
}
156174
if let Some(configure_shell_profile) = configure_shell_profile {
157175
buf.append(&mut configure_shell_profile.describe_execute());
158176
}
@@ -165,6 +183,7 @@ impl Action for ConfigureNix {
165183
setup_default_profile,
166184
place_nix_configuration,
167185
configure_shell_profile,
186+
setup_channels,
168187
} = self;
169188

170189
if let Some(place_nix_configuration) = place_nix_configuration {
@@ -177,6 +196,10 @@ impl Action for ConfigureNix {
177196
.try_execute()
178197
.await
179198
.map_err(Self::error)?;
199+
let setup_default_profile_span = tracing::Span::current().clone();
200+
setup_channels
201+
.is_some()
202+
.then(|| setup_default_profile_span.clone());
180203
if let Some(configure_shell_profile) = configure_shell_profile {
181204
configure_shell_profile
182205
.try_execute()
@@ -192,6 +215,7 @@ impl Action for ConfigureNix {
192215
setup_default_profile,
193216
place_nix_configuration,
194217
configure_shell_profile,
218+
setup_channels,
195219
} = &self;
196220

197221
let mut buf = Vec::default();
@@ -202,6 +226,9 @@ impl Action for ConfigureNix {
202226
buf.append(&mut place_nix_configuration.describe_revert());
203227
}
204228
buf.append(&mut setup_default_profile.describe_revert());
229+
if let Some(setup_channels) = setup_channels {
230+
buf.append(&mut setup_channels.describe_revert());
231+
}
205232

206233
buf
207234
}
@@ -223,6 +250,12 @@ impl Action for ConfigureNix {
223250
errors.push(err);
224251
}
225252

253+
if let Some(setup_channels) = &mut self.setup_channels {
254+
if let Err(err) = setup_channels.try_revert().await {
255+
errors.push(err);
256+
}
257+
}
258+
226259
if errors.is_empty() {
227260
Ok(())
228261
} else if errors.len() == 1 {

src/settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl CommonSettings {
241241
force: false,
242242
skip_nix_conf: false,
243243
ssl_cert_file: Default::default(),
244-
add_channel: false,
244+
add_channel: true,
245245
})
246246
}
247247

0 commit comments

Comments
 (0)