diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 31bf1f7..a938dbb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/Cargo.lock b/Cargo.lock index c4fd274..5a21915 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -606,7 +606,7 @@ dependencies = [ [[package]] name = "harmonic" -version = "0.0.1" +version = "0.0.0-unreleased" dependencies = [ "async-tar", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 03e52ce..63fd5c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "harmonic" description = "A `nix` installer" -version = "0.0.1" +version = "0.0.0-unreleased" edition = "2021" resolver = "2" diff --git a/nix/ci.nix b/nix/ci.nix index e5017d5..6bb6b2f 100644 --- a/nix/ci.nix +++ b/nix/ci.nix @@ -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 '') ] diff --git a/src/cli/arg/instrumentation.rs b/src/cli/arg/instrumentation.rs index 13efbb4..efd5569 100644 --- a/src/cli/arg/instrumentation.rs +++ b/src/cli/arg/instrumentation.rs @@ -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, } diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 9f43ebd..20a2723 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -11,22 +11,34 @@ pub(crate) trait CommandExecute { async fn execute(self) -> eyre::Result; } +/// 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, + pub(crate) channel: Vec, + /// 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, @@ -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::>().join(", "), + channels = %self.channel.iter().map(|ChannelValue(name, url)| format!("{name} {url}")).collect::>().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)