Skip to content

Commit

Permalink
feat: add LegacyArgs, --store, and --eval-store (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkenigs authored Aug 1, 2023
1 parent ef609b6 commit 1939997
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
25 changes: 17 additions & 8 deletions crates/runix/src/arguments/common.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
//! Arguments common for all mix commands

use derive_more::{Deref, From};
use runix_derive::ToArgs;

use crate::command_line::flag::{Flag, FlagType};
use crate::command_line::ToArgs;

/// These arguments do not depend on the nix subcommand issued
/// and refer to the options defined in
/// - (libmain/common-args.cc)[https://github.com/NixOS/nix/blob/a6239eb5700ebb85b47bb5f12366404448361f8d/src/libmain/common-args.cc#L7-L81]
/// - (nix/main.cc)[https://github.com/NixOS/nix/blob/b7e8a3bf4cbb2448db860f65ea13ef2c64b6883b/src/nix/main.cc#L66-L110]
#[derive(Clone, Default, Debug)]
pub struct NixCommonArgs {}
impl ToArgs for NixCommonArgs {
fn to_args(&self) -> Vec<String> {
vec![]
}
/// - [libmain/common-args.cc](https://github.com/NixOS/nix/blob/a6239eb5700ebb85b47bb5f12366404448361f8d/src/libmain/common-args.cc#L7-L81)
/// - [libmain/shared.cc](https://github.com/NixOS/nix/blob/2d1d81114d72ace89ce08cd3bc93f4eb27a2975d/src/libmain/shared.cc#L177-L245)
/// - [nix/main.cc](https://github.com/NixOS/nix/blob/b7e8a3bf4cbb2448db860f65ea13ef2c64b6883b/src/nix/main.cc#L66-L110)
#[derive(Clone, Default, Debug, ToArgs)]
pub struct NixCommonArgs {
pub store: Option<Store>,
}

#[derive(Clone, From, Debug, Deref, Default)]
pub struct Store(String);
impl Flag for Store {
const FLAG: &'static str = "--store";
const FLAG_TYPE: FlagType<Self> = FlagType::arg();
}
8 changes: 8 additions & 0 deletions crates/runix/src/arguments/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ use crate::default::flag::{Flag, FlagType};
/// [libcmd/common-eval-args.cc](https://github.com/NixOS/nix/blob/a6239eb5700ebb85b47bb5f12366404448361f8d/src/libcmd/common-eval-args.cc#L14-L74)
#[derive(Clone, Default, Debug, ToArgs)]
pub struct EvaluationArgs {
pub eval_store: Option<EvalStore>,
pub impure: Impure,
}

#[derive(Clone, From, Debug, Deref, Default)]
pub struct EvalStore(String);
impl Flag for EvalStore {
const FLAG: &'static str = "--eval-store";
const FLAG_TYPE: FlagType<Self> = FlagType::arg();
}

#[derive(Clone, From, Debug, Deref, Default)]
pub struct Impure(bool);
impl Flag for Impure {
Expand Down

0 comments on commit 1939997

Please sign in to comment.