mirror of
https://github.com/callumio/nish.git
synced 2025-12-18 03:59:19 +00:00
feat: shell for packages and custom flakes
This commit is contained in:
parent
89c01b9845
commit
0e3dc2cc29
4 changed files with 1101 additions and 1 deletions
1049
Cargo.lock
generated
1049
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -4,3 +4,6 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.5.17", features = ["derive"] }
|
||||
runix = "0.1.1"
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
|
|
|
|||
|
|
@ -73,4 +73,9 @@
|
|||
};
|
||||
}
|
||||
);
|
||||
|
||||
nixConfig = {
|
||||
extra-substituters = ["callumio-public.cachix.org"];
|
||||
extra-trusted-public-keys = ["callumio-public.cachix.org-1:VucOSl7vh44GdqcILwMIeHlI0ufuAnHAl8cO1U/7yhg="];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
45
src/main.rs
45
src/main.rs
|
|
@ -1 +1,44 @@
|
|||
fn main() {}
|
||||
use clap::Parser;
|
||||
use runix::{
|
||||
arguments::{
|
||||
eval::EvaluationArgs, flake::FlakeArgs, source::SourceArgs, InstallablesArgs, NixArgs,
|
||||
},
|
||||
command::Shell,
|
||||
default::NixCommandLine,
|
||||
installable::Installable,
|
||||
Run,
|
||||
};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about)]
|
||||
struct Args {
|
||||
/// List of packages to include in the shell.
|
||||
///
|
||||
/// <package> to implicitly use nixpkgs
|
||||
///
|
||||
/// <flake#package> to use a different flake
|
||||
#[arg(value_parser = preprocess)]
|
||||
pkgs: Vec<Installable>,
|
||||
}
|
||||
|
||||
fn preprocess(s: &str) -> Result<Installable, String> {
|
||||
Ok(Installable::from(if s.contains('#') {
|
||||
s.to_owned()
|
||||
} else {
|
||||
format!("nixpkgs#{}", s)
|
||||
}))
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), runix::default::NixCommandLineRunError> {
|
||||
let cli = Args::parse();
|
||||
dbg!(&cli.pkgs);
|
||||
Shell {
|
||||
flake: FlakeArgs::default(),
|
||||
eval: EvaluationArgs::default(),
|
||||
source: SourceArgs::default(),
|
||||
installables: InstallablesArgs::from(cli.pkgs),
|
||||
}
|
||||
.run(&NixCommandLine::default(), &NixArgs::default())
|
||||
.await
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue