Skip to content

Commit

Permalink
init darwin impl
Browse files Browse the repository at this point in the history
  • Loading branch information
viperML committed Nov 19, 2024
1 parent 8195c25 commit 9e53b0a
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ fn profiles_in_dir<P: AsRef<Path> + fmt::Debug>(dir: P) -> Vec<PathBuf> {

let generation_regex = Regex::new(r"^(.*)-(\d+)-link$").unwrap();

if let Some(_) = generation_regex.captures(&name) {
if generation_regex.captures(&name).is_some() {
res.push(path);
}
}
Expand Down
30 changes: 30 additions & 0 deletions src/darwin.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use crate::interface::{DarwinArgs, DarwinRebuildArgs, DarwinReplArgs, DarwinSubcommand};
use crate::Result;

impl DarwinArgs {
pub fn run(self) -> Result<()> {
use DarwinRebuildVariant::*;
match self.subcommand {
DarwinSubcommand::Switch(args) => args.rebuild(Switch),
DarwinSubcommand::Build(args) => args.rebuild(Build),
DarwinSubcommand::Repl(args) => args.run(),
}
}
}

enum DarwinRebuildVariant {
Switch,
Build,
}

impl DarwinRebuildArgs {
fn rebuild(self, _variant: DarwinRebuildVariant) -> Result<()> {
todo!();
}
}

impl DarwinReplArgs {
fn run(self) -> Result<()> {
todo!();
}
}
5 changes: 0 additions & 5 deletions src/home.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ use crate::commands::Command;
use crate::installable::Installable;
use crate::interface::{self, HomeRebuildArgs};

const SYSTEM_PROFILE: &str = "/nix/var/nix/profiles/system";
const CURRENT_PROFILE: &str = "/run/current-system";

const SPEC_LOCATION: &str = "/etc/specialisation";

impl interface::HomeArgs {
pub fn run(self) -> Result<()> {
use HomeRebuildVariant::*;
Expand Down
29 changes: 28 additions & 1 deletion src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ pub struct Main {
#[command(disable_help_subcommand = true)]
pub enum NHCommand {
Os(OsArgs),
Home(HomeArgs),
Darwin(DarwinArgs),
Search(SearchArgs),
Clean(CleanProxy),
Home(HomeArgs),
#[command(hide = true)]
Completions(CompletionArgs),
}
Expand All @@ -59,6 +60,7 @@ impl NHCommand {
NHCommand::Clean(proxy) => proxy.command.run(),
NHCommand::Completions(args) => args.run(),
NHCommand::Home(args) => args.run(),
NHCommand::Darwin(args) => args.run(),
}
}
}
Expand Down Expand Up @@ -279,3 +281,28 @@ pub struct CompletionArgs {
/// Name of the shell
pub shell: clap_complete::Shell,
}

#[derive(Debug, Args)]
pub struct DarwinArgs {
#[command(subcommand)]
pub subcommand: DarwinSubcommand,
}

#[derive(Debug, Subcommand)]
pub enum DarwinSubcommand {
Switch(DarwinRebuildArgs),
Build(DarwinRebuildArgs),
Repl(DarwinReplArgs),
}

#[derive(Debug, Args)]
pub struct DarwinRebuildArgs {
#[command(flatten)]
pub common: CommonRebuildArgs,
}

#[derive(Debug, Args)]
pub struct DarwinReplArgs {
#[command(flatten)]
pub installable: Installable,
}
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod clean;
mod commands;
mod completion;
mod darwin;
mod home;
mod installable;
mod interface;
Expand Down
2 changes: 1 addition & 1 deletion src/search.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::process::Stdio;
use std::time::Instant;

use color_eyre::eyre::{bail, Context, ContextCompat};
use color_eyre::eyre::{bail, Context};
use elasticsearch_dsl::*;
use interface::SearchArgs;
use regex::Regex;
Expand Down

0 comments on commit 9e53b0a

Please sign in to comment.