Prod at CI with a stick
Signed-off-by: Ana Hobden <operator@hoverbear.org>
This commit is contained in:
parent
3a3a7af3f3
commit
82523e43a6
11
.github/workflows/ci.yml
vendored
11
.github/workflows/ci.yml
vendored
|
@ -39,17 +39,6 @@ jobs:
|
|||
- name: Check nixpkgs-fmt formatting
|
||||
run: nix develop --command ci-check-nixpkgs-fmt
|
||||
|
||||
RegistryFormatting:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v17
|
||||
with:
|
||||
extra_nix_config: |
|
||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Check registry.json formatting
|
||||
run: nix develop --command ci-check-registry-format
|
||||
|
||||
EditorConfig:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
|
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -606,7 +606,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "harmonic"
|
||||
version = "0.0.1"
|
||||
version = "0.0.0-unreleased"
|
||||
dependencies = [
|
||||
"async-tar",
|
||||
"async-trait",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "harmonic"
|
||||
description = "A `nix` installer"
|
||||
version = "0.0.1"
|
||||
version = "0.0.0-unreleased"
|
||||
edition = "2021"
|
||||
resolver = "2"
|
||||
|
||||
|
|
|
@ -24,11 +24,6 @@ in
|
|||
git ls-files '*.nix' | xargs | nixpkgs-fmt --check
|
||||
'')
|
||||
|
||||
# RegistryFormatting
|
||||
(writeScriptBin "ci-check-registry-format" ''
|
||||
./registry/format.sh && git diff --exit-code
|
||||
'')
|
||||
|
||||
# EditorConfig
|
||||
(writeScriptBin "ci-check-editorconfig" ''
|
||||
eclint
|
||||
|
@ -39,7 +34,6 @@ in
|
|||
ci-test-rust
|
||||
ci-check-spelling
|
||||
ci-check-nixpkgs-fmt
|
||||
ci-check-registry-format
|
||||
ci-check-editorconfig
|
||||
'')
|
||||
]
|
||||
|
|
|
@ -8,13 +8,7 @@ use valuable::Valuable;
|
|||
#[derive(clap::Args, Debug, Valuable)]
|
||||
pub struct Instrumentation {
|
||||
/// Enable debug logs, -vv for trace
|
||||
#[clap(
|
||||
short = 'v',
|
||||
long,
|
||||
parse(from_occurrences),
|
||||
global = true,
|
||||
group = "verbosity"
|
||||
)]
|
||||
#[clap(short = 'v', long, parse(from_occurrences), global = true)]
|
||||
pub(crate) verbose: usize,
|
||||
}
|
||||
|
||||
|
|
|
@ -11,22 +11,34 @@ pub(crate) trait CommandExecute {
|
|||
async fn execute(self) -> eyre::Result<ExitCode>;
|
||||
}
|
||||
|
||||
/// An opinionated, experimental Nix installer
|
||||
#[derive(Debug, Parser)]
|
||||
#[clap(version)]
|
||||
pub(crate) struct HarmonicCli {
|
||||
#[clap(long, action(ArgAction::SetTrue), default_value = "false")]
|
||||
// Don't actually install, just log expected actions
|
||||
#[clap(
|
||||
long,
|
||||
action(ArgAction::SetTrue),
|
||||
default_value = "false",
|
||||
global = true
|
||||
)]
|
||||
pub(crate) dry_run: bool,
|
||||
#[clap(flatten)]
|
||||
pub(crate) instrumentation: arg::Instrumentation,
|
||||
/// Channel(s) to add by default, pass multiple times for multiple channels
|
||||
#[clap(
|
||||
long,
|
||||
value_parser,
|
||||
action = clap::ArgAction::Append,
|
||||
env = "HARMONIC_CHANNEL",
|
||||
default_value = "nixpkgs=https://nixos.org/channels/nixpkgs-unstable"
|
||||
)]
|
||||
pub(crate) channels: Vec<arg::ChannelValue>,
|
||||
pub(crate) channel: Vec<arg::ChannelValue>,
|
||||
/// Don't modify the user profile to automatically load nix
|
||||
#[clap(long)]
|
||||
pub(crate) no_modify_profile: bool,
|
||||
#[clap(long, default_value = "32")]
|
||||
/// Number of build users to create
|
||||
#[clap(long, default_value = "32", env = "HARMONIC_NIX_DAEMON_USER_COUNT")]
|
||||
pub(crate) daemon_user_count: usize,
|
||||
#[clap(subcommand)]
|
||||
subcommand: Option<subcommand::Subcommand>,
|
||||
|
@ -35,7 +47,7 @@ pub(crate) struct HarmonicCli {
|
|||
#[async_trait::async_trait]
|
||||
impl CommandExecute for HarmonicCli {
|
||||
#[tracing::instrument(skip_all, fields(
|
||||
channels = %self.channels.iter().map(|ChannelValue(name, url)| format!("{name} {url}")).collect::<Vec<_>>().join(", "),
|
||||
channels = %self.channel.iter().map(|ChannelValue(name, url)| format!("{name} {url}")).collect::<Vec<_>>().join(", "),
|
||||
daemon_user_count = %self.daemon_user_count,
|
||||
no_modify_profile = %self.no_modify_profile,
|
||||
dry_run = %self.dry_run,
|
||||
|
@ -45,12 +57,13 @@ impl CommandExecute for HarmonicCli {
|
|||
dry_run,
|
||||
instrumentation: _,
|
||||
daemon_user_count,
|
||||
channels,
|
||||
channel,
|
||||
no_modify_profile,
|
||||
subcommand,
|
||||
} = self;
|
||||
|
||||
match subcommand {
|
||||
#[cfg(target_os = "linux")]
|
||||
Some(subcommand::Subcommand::NixOs(nixos)) => return nixos.execute().await,
|
||||
None => (),
|
||||
}
|
||||
|
@ -60,13 +73,31 @@ impl CommandExecute for HarmonicCli {
|
|||
harmonic.dry_run(dry_run);
|
||||
harmonic.daemon_user_count(daemon_user_count);
|
||||
harmonic.channels(
|
||||
channels
|
||||
channel
|
||||
.into_iter()
|
||||
.map(|ChannelValue(name, url)| (name, url)),
|
||||
);
|
||||
harmonic.modify_profile(!no_modify_profile);
|
||||
|
||||
if !interaction::confirm("Are you ready to continue?").await? {
|
||||
// TODO(@Hoverbear): Make this smarter
|
||||
if !interaction::confirm(
|
||||
"\
|
||||
Ready to install nix?\n\
|
||||
\n\
|
||||
This installer will:\n\
|
||||
\n\
|
||||
* Create a `nixbld` group\n\
|
||||
* Create several `nixbld*` users\n\
|
||||
* Create several Nix related directories\n\
|
||||
* Place channel configurations\n\
|
||||
* Fetch a copy of Nix and unpack it\n\
|
||||
* Configure the shell profiles of various shells\n\
|
||||
* Place a Nix configuration\n\
|
||||
* Configure the Nix daemon to work with your init\
|
||||
",
|
||||
)
|
||||
.await?
|
||||
{
|
||||
interaction::clean_exit_with_message("Okay, didn't do anything! Bye!").await;
|
||||
}
|
||||
|
||||
|
@ -78,7 +109,6 @@ impl CommandExecute for HarmonicCli {
|
|||
harmonic.configure_shell_profile().await?;
|
||||
harmonic.setup_default_profile().await?;
|
||||
harmonic.place_nix_configuration().await?;
|
||||
|
||||
harmonic.configure_nix_daemon_service().await?;
|
||||
|
||||
Ok(ExitCode::SUCCESS)
|
||||
|
|
Loading…
Reference in a new issue