runix/arguments/
flake.rs

1//! Flake related arguments, see [FlakeArgs]
2
3use derive_more::{Constructor, Deref, From};
4use runix_derive::ToArgs;
5
6use crate::command_line::flag::{Flag, FlagType};
7use crate::command_line::ToArgs;
8use crate::installable::FlakeRef;
9
10/// Flake related arguments
11/// Corresponding to the arguments defined in
12/// [libcmd/installables.cc](https://github.com/NixOS/nix/blob/84cc7ad77c6faf1cda8f8a10f7c12a939b61fe35/src/libcmd/installables.cc#L26-L126)
13#[derive(Clone, Default, Debug, ToArgs)]
14pub struct FlakeArgs {
15    pub override_inputs: Vec<OverrideInput>,
16    pub no_write_lock_file: NoWriteLockFile,
17}
18
19/// Tuple like override inputs flag
20#[derive(Clone, Debug, From, Constructor)]
21pub struct OverrideInput {
22    pub from: FlakeRef,
23    pub to: FlakeRef,
24}
25impl Flag for OverrideInput {
26    const FLAG: &'static str = "--override-input";
27    const FLAG_TYPE: FlagType<Self> = FlagType::Args(Self::args);
28}
29impl OverrideInput {
30    fn args(&self) -> Vec<String> {
31        vec![self.from.clone(), self.to.clone()]
32    }
33}
34
35/// Flag for no-write-lock-file
36#[derive(Clone, From, Debug, Deref, Default)]
37pub struct NoWriteLockFile(bool);
38impl Flag for NoWriteLockFile {
39    const FLAG: &'static str = "--no-write-lock-file";
40    /// Not a config/switch.
41    /// There is no `--write-lock-file` equivalent
42    const FLAG_TYPE: FlagType<Self> = FlagType::bool();
43}