Skip to content

Commit b3e0c63

Browse files
committed
Update binary name to yeet
1 parent 4162ba5 commit b3e0c63

File tree

3 files changed

+39
-52
lines changed

3 files changed

+39
-52
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,30 @@ SPDX-License-Identifier: MPL-2.0
1111

1212
A Simple, multi-profile Nix-flake deploy tool.
1313

14-
Questions? Need help? Join us on Matrix: [`#yeet:matrix.org`](https://matrix.to/#/#yeet:matrix.org)
14+
Questions? Need help? Join us on Matrix: [`#yeet:nixos.org`](https://matrix.to/#/#yeet:nixos.org)
1515

1616
## Usage
1717

18-
Basic usage: `deploy [options] <flake>`.
18+
Basic usage: `yeet [options] <flake>`.
1919

2020
Using this method all profiles specified in the given `<flake>` will be deployed (taking into account the [`profilesOrder`](#node)).
2121

2222
Optionally the flake can be constrained to deploy just a single node (`my-flake#my-node`) or a profile (`my-flake#my-node.my-profile`).
2323

2424
If your profile or node name has a . in it, simply wrap it in quotes, and the flake path in quotes (to avoid shell escaping), for example 'my-flake."myserver.com".system'.
2525

26-
Any "extra" arguments will be passed into the Nix calls, so for instance to deploy an impure profile, you may use `deploy . -- --impure` (note the explicit flake path is necessary for doing this).
26+
Any "extra" arguments will be passed into the Nix calls, so for instance to deploy an impure profile, you may use `yeet . -- --impure` (note the explicit flake path is necessary for doing this).
2727

2828
You can try out this tool easily with `nix run`:
2929
- `nix run github:serokell/yeet your-flake`
3030

31-
In you want to deploy multiple flakes or a subset of profiles with one invocation, instead of calling `deploy <flake>` you can issue `deploy --targets <flake> [<flake> ...]` where `<flake>` is supposed to take the same format as discussed before.
31+
In you want to deploy multiple flakes or a subset of profiles with one invocation, instead of calling `yeet <flake>` you can issue `yeet --targets <flake> [<flake> ...]` where `<flake>` is supposed to take the same format as discussed before.
3232

3333
Running in this mode, if any of the deploys fails, the deploy will be aborted and all successful deploys rolled back. `--rollback-succeeded false` can be used to override this behavior, otherwise the `auto-rollback` argument takes precedent.
3434

3535
If you require a signing key to push closures to your server, specify the path to it in the `LOCAL_KEY` environment variable.
3636

37-
Check out `deploy --help` for CLI flags! Remember to check there before making one-time changes to things like hostnames.
37+
Check out `yeet --help` for CLI flags! Remember to check there before making one-time changes to things like hostnames.
3838

3939
There is also an `activate` binary though this should be ignored, it is only used internally (on the deployed system) and for testing/hacking purposes.
4040

@@ -115,7 +115,7 @@ This defines a single node/server, and the profiles you intend it to run.
115115
hostname = "my.server.gov";
116116
117117
# An optional list containing the order you want profiles to be deployed.
118-
# This will take effect whenever you run `deploy` without specifying a profile, causing it to deploy every profile automatically.
118+
# This will take effect whenever you run `yeet` without specifying a profile, causing it to deploy every profile automatically.
119119
# Any profiles not in this list will still be deployed (in an arbitrary order) after those which are listed
120120
profilesOrder = [ "something" "system" ];
121121
File renamed without changes.

src/cli.rs

Lines changed: 33 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ use std::io::{stdin, stdout, Write};
88

99
use clap::{ArgMatches, Clap, FromArgMatches};
1010

11-
use crate as deploy;
11+
use crate as yeet;
1212

13-
use self::deploy::{DeployFlake, ParseFlakeError};
13+
use self::yeet::{DeployFlake, ParseFlakeError};
1414
use futures_util::stream::{StreamExt, TryStreamExt};
1515
use log::{debug, error, info, warn};
1616
use serde::Serialize;
1717
use std::process::Stdio;
1818
use thiserror::Error;
1919
use tokio::process::Command;
2020

21-
/// Simple Rust rewrite of a simple Nix Flake deployment tool
21+
/// A simple multi-profile Nix-flake deploy tool.
2222
#[derive(Clap, Debug, Clone)]
2323
#[clap(version = "1.0", author = "Serokell <https://serokell.io/>")]
2424
pub struct Opts {
@@ -168,9 +168,9 @@ pub enum GetDeploymentDataError {
168168
/// Evaluates the Nix in the given `repo` and return the processed Data from it
169169
async fn get_deployment_data(
170170
supports_flakes: bool,
171-
flakes: &[deploy::DeployFlake<'_>],
171+
flakes: &[yeet::DeployFlake<'_>],
172172
extra_build_args: &[String],
173-
) -> Result<Vec<deploy::data::Data>, GetDeploymentDataError> {
173+
) -> Result<Vec<yeet::data::Data>, GetDeploymentDataError> {
174174
futures_util::stream::iter(flakes).then(|flake| async move {
175175

176176
info!("Evaluating flake in {}", flake.repo);
@@ -271,11 +271,7 @@ struct PromptPart<'a> {
271271
}
272272

273273
fn print_deployment(
274-
parts: &[(
275-
&deploy::DeployFlake<'_>,
276-
deploy::DeployData,
277-
deploy::DeployDefs,
278-
)],
274+
parts: &[(&yeet::DeployFlake<'_>, yeet::DeployData, yeet::DeployDefs)],
279275
) -> Result<(), toml::ser::Error> {
280276
let mut part_map: HashMap<String, HashMap<String, PromptPart>> = HashMap::new();
281277

@@ -314,11 +310,7 @@ pub enum PromptDeploymentError {
314310
}
315311

316312
fn prompt_deployment(
317-
parts: &[(
318-
&deploy::DeployFlake<'_>,
319-
deploy::DeployData,
320-
deploy::DeployDefs,
321-
)],
313+
parts: &[(&yeet::DeployFlake<'_>, yeet::DeployData, yeet::DeployDefs)],
322314
) -> Result<(), PromptDeploymentError> {
323315
print_deployment(parts)?;
324316

@@ -368,39 +360,39 @@ fn prompt_deployment(
368360
#[derive(Error, Debug)]
369361
pub enum RunDeployError {
370362
#[error("Failed to deploy profile: {0}")]
371-
DeployProfile(#[from] deploy::deploy::DeployProfileError),
363+
DeployProfile(#[from] yeet::deploy::DeployProfileError),
372364
#[error("Failed to push profile: {0}")]
373-
PushProfile(#[from] deploy::push::PushProfileError),
365+
PushProfile(#[from] yeet::push::PushProfileError),
374366
#[error("No profile named `{0}` was found")]
375367
ProfileNotFound(String),
376368
#[error("No node named `{0}` was found")]
377369
NodeNotFound(String),
378370
#[error("Profile was provided without a node name")]
379371
ProfileWithoutNode,
380372
#[error("Error processing deployment definitions: {0}")]
381-
DeployDataDefs(#[from] deploy::DeployDataDefsError),
373+
DeployDataDefs(#[from] yeet::DeployDataDefsError),
382374
#[error("Failed to make printable TOML of deployment: {0}")]
383375
TomlFormat(#[from] toml::ser::Error),
384376
#[error("{0}")]
385377
PromptDeployment(#[from] PromptDeploymentError),
386378
#[error("Failed to revoke profile: {0}")]
387-
RevokeProfile(#[from] deploy::deploy::RevokeProfileError),
379+
RevokeProfile(#[from] yeet::deploy::RevokeProfileError),
388380
}
389381

390382
type ToDeploy<'a> = Vec<(
391-
&'a deploy::DeployFlake<'a>,
392-
&'a deploy::data::Data,
393-
(&'a str, &'a deploy::data::Node),
394-
(&'a str, &'a deploy::data::Profile),
383+
&'a yeet::DeployFlake<'a>,
384+
&'a yeet::data::Data,
385+
(&'a str, &'a yeet::data::Node),
386+
(&'a str, &'a yeet::data::Profile),
395387
)>;
396388

397389
async fn run_deploy(
398-
deploy_flakes: Vec<deploy::DeployFlake<'_>>,
399-
data: Vec<deploy::data::Data>,
390+
deploy_flakes: Vec<yeet::DeployFlake<'_>>,
391+
data: Vec<yeet::data::Data>,
400392
supports_flakes: bool,
401393
check_sigs: bool,
402394
interactive: bool,
403-
cmd_overrides: &deploy::CmdOverrides,
395+
cmd_overrides: &yeet::CmdOverrides,
404396
keep_result: bool,
405397
result_path: Option<&str>,
406398
extra_build_args: &[String],
@@ -437,7 +429,7 @@ async fn run_deploy(
437429
None => return Err(RunDeployError::NodeNotFound(node_name.clone())),
438430
};
439431

440-
let mut profiles_list: Vec<(&str, &deploy::data::Profile)> = Vec::new();
432+
let mut profiles_list: Vec<(&str, &yeet::data::Profile)> = Vec::new();
441433

442434
for profile_name in [
443435
node.node_settings.profiles_order.iter().collect(),
@@ -466,7 +458,7 @@ async fn run_deploy(
466458
let mut l = Vec::new();
467459

468460
for (node_name, node) in &data.nodes {
469-
let mut profiles_list: Vec<(&str, &deploy::data::Profile)> = Vec::new();
461+
let mut profiles_list: Vec<(&str, &yeet::data::Profile)> = Vec::new();
470462

471463
for profile_name in [
472464
node.node_settings.profiles_order.iter().collect(),
@@ -507,14 +499,10 @@ async fn run_deploy(
507499
.flatten()
508500
.collect();
509501

510-
let mut parts: Vec<(
511-
&deploy::DeployFlake<'_>,
512-
deploy::DeployData,
513-
deploy::DeployDefs,
514-
)> = Vec::new();
502+
let mut parts: Vec<(&yeet::DeployFlake<'_>, yeet::DeployData, yeet::DeployDefs)> = Vec::new();
515503

516504
for (deploy_flake, data, (node_name, node), (profile_name, profile)) in to_deploy {
517-
let deploy_data = deploy::make_deploy_data(
505+
let deploy_data = yeet::make_deploy_data(
518506
&data.generic_settings,
519507
node,
520508
node_name,
@@ -537,7 +525,7 @@ async fn run_deploy(
537525
}
538526

539527
for (deploy_flake, deploy_data, deploy_defs) in &parts {
540-
deploy::push::push_profile(deploy::push::PushProfileData {
528+
yeet::push::push_profile(yeet::push::PushProfileData {
541529
supports_flakes,
542530
check_sigs,
543531
repo: deploy_flake.repo,
@@ -550,15 +538,14 @@ async fn run_deploy(
550538
.await?;
551539
}
552540

553-
let mut succeeded: Vec<(&deploy::DeployData, &deploy::DeployDefs)> = vec![];
541+
let mut succeeded: Vec<(&yeet::DeployData, &yeet::DeployDefs)> = vec![];
554542

555543
// Run all deployments
556544
// In case of an error rollback any previoulsy made deployment.
557545
// Rollbacks adhere to the global seeting to auto_rollback and secondary
558546
// the profile's configuration
559547
for (_, deploy_data, deploy_defs) in &parts {
560-
if let Err(e) = deploy::deploy::deploy_profile(deploy_data, deploy_defs, dry_activate).await
561-
{
548+
if let Err(e) = yeet::deploy::deploy_profile(deploy_data, deploy_defs, dry_activate).await {
562549
error!("{}", e);
563550
if dry_activate {
564551
info!("dry run, not rolling back");
@@ -570,7 +557,7 @@ async fn run_deploy(
570557
// the command line)
571558
for (deploy_data, deploy_defs) in &succeeded {
572559
if deploy_data.merged_settings.auto_rollback.unwrap_or(true) {
573-
deploy::deploy::revoke(*deploy_data, *deploy_defs).await?;
560+
yeet::deploy::revoke(*deploy_data, *deploy_defs).await?;
574561
}
575562
}
576563
}
@@ -585,17 +572,17 @@ async fn run_deploy(
585572
#[derive(Error, Debug)]
586573
pub enum RunError {
587574
#[error("Failed to deploy profile: {0}")]
588-
DeployProfile(#[from] deploy::deploy::DeployProfileError),
575+
DeployProfile(#[from] yeet::deploy::DeployProfileError),
589576
#[error("Failed to push profile: {0}")]
590-
PushProfile(#[from] deploy::push::PushProfileError),
577+
PushProfile(#[from] yeet::push::PushProfileError),
591578
#[error("Failed to test for flake support: {0}")]
592579
FlakeTest(std::io::Error),
593580
#[error("Failed to check deployment: {0}")]
594581
CheckDeployment(#[from] CheckDeploymentError),
595582
#[error("Failed to evaluate deployment data: {0}")]
596583
GetDeploymentData(#[from] GetDeploymentDataError),
597584
#[error("Error parsing flake: {0}")]
598-
ParseFlake(#[from] deploy::ParseFlakeError),
585+
ParseFlake(#[from] yeet::ParseFlakeError),
599586
#[error("Error initiating logger: {0}")]
600587
Logger(#[from] flexi_logger::FlexiLoggerError),
601588
#[error("{0}")]
@@ -608,10 +595,10 @@ pub async fn run(args: Option<&ArgMatches>) -> Result<(), RunError> {
608595
None => Opts::parse(),
609596
};
610597

611-
deploy::init_logger(
598+
yeet::init_logger(
612599
opts.debug_logs,
613600
opts.log_dir.as_deref(),
614-
&deploy::LoggerType::Deploy,
601+
&yeet::LoggerType::Deploy,
615602
)?;
616603

617604
let deploys = opts
@@ -621,10 +608,10 @@ pub async fn run(args: Option<&ArgMatches>) -> Result<(), RunError> {
621608

622609
let deploy_flakes: Vec<DeployFlake> = deploys
623610
.iter()
624-
.map(|f| deploy::parse_flake(f.as_str()))
611+
.map(|f| yeet::parse_flake(f.as_str()))
625612
.collect::<Result<Vec<DeployFlake>, ParseFlakeError>>()?;
626613

627-
let cmd_overrides = deploy::CmdOverrides {
614+
let cmd_overrides = yeet::CmdOverrides {
628615
ssh_user: opts.ssh_user,
629616
profile_user: opts.profile_user,
630617
ssh_opts: opts.ssh_opts,

0 commit comments

Comments
 (0)