feat: unfree flag
Some checks failed
build / tests (push) Has been cancelled

This commit is contained in:
Callum Leslie 2026-03-30 09:54:45 +01:00
parent e0d8eec64f
commit 68b1835617
Signed by: cleslie
GPG key ID: D382C4AFEECEAA90

View file

@ -12,6 +12,10 @@ use runix::{
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[command(version, about)] #[command(version, about)]
struct Args { struct Args {
/// Enables unfree packages, if not already allowed by the local Nix config
#[arg(short = 'u', long, required = false)]
allow_unfree: bool,
/// List of packages to include in the shell. /// List of packages to include in the shell.
/// ///
/// <package> to implicitly use nixpkgs /// <package> to implicitly use nixpkgs
@ -25,16 +29,20 @@ fn preprocess(s: &str) -> Result<Installable, String> {
Ok(Installable::from(if s.contains('#') { Ok(Installable::from(if s.contains('#') {
s.to_owned() s.to_owned()
} else { } else {
format!("nixpkgs#{}", s) format!("nixpkgs#{s}")
})) }))
} }
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), runix::default::NixCommandLineRunError> { async fn main() -> Result<(), runix::default::NixCommandLineRunError> {
let cli = Args::parse(); let cli = Args::parse();
std::env::set_var("NIXPKGS_ALLOW_UNFREE", "1");
Shell { Shell {
flake: FlakeArgs::default(), flake: FlakeArgs::default(),
eval: EvaluationArgs::default(), eval: EvaluationArgs {
impure: cli.allow_unfree.into(),
},
source: SourceArgs::default(), source: SourceArgs::default(),
installables: InstallablesArgs::from(cli.pkgs), installables: InstallablesArgs::from(cli.pkgs),
} }