Skip to content

Commit 10eddfd

Browse files
committed
devenv: support pkg as a type for --option
For example: `devenv shell --option "languages.java.jdk.package" "graalvm-oracle"`
1 parent 0b4ce92 commit 10eddfd

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

devenv/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ pub struct GlobalOptions {
166166
num_args = 2,
167167
value_names = ["OPTION", "VALUE"],
168168
help = "Override configuration options with typed values",
169-
long_help = "Override configuration options with typed values.\n\nOPTION must include a type: <attribute>:<type>\nSupported types: string, int, float, bool, path, pkgs\n\nExamples:\n --option languages.rust.channel:string beta\n --option services.postgres.enable:bool true\n --option languages.python.version:string 3.10\n --option packages:pkgs \"ncdu git\""
169+
long_help = "Override configuration options with typed values.\n\nOPTION must include a type: <attribute>:<type>\nSupported types: string, int, float, bool, path, pkg, pkgs\n\nExamples:\n --option languages.rust.channel:string beta\n --option services.postgres.enable:bool true\n --option languages.python.version:string 3.10\n --option packages:pkgs \"ncdu git\""
170170
)]
171171
pub option: Vec<String>,
172172
}

devenv/src/devenv.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,8 @@ impl Devenv {
10751075
if !self.global_options.option.is_empty() {
10761076
let mut cli_options = String::from("{ pkgs, lib, config, ... }: {\n");
10771077

1078-
const SUPPORTED_TYPES: &[&str] = &["string", "int", "float", "bool", "path", "pkgs"];
1078+
const SUPPORTED_TYPES: &[&str] =
1079+
&["string", "int", "float", "bool", "path", "pkg", "pkgs"];
10791080

10801081
for chunk in self.global_options.option.chunks_exact(2) {
10811082
// Parse the path and type from the first value
@@ -1095,6 +1096,7 @@ impl Devenv {
10951096
"float" => chunk[1].clone(),
10961097
"bool" => chunk[1].clone(), // true/false will work directly in Nix
10971098
"path" => format!("./{}", &chunk[1]), // relative path
1099+
"pkg" => format!("pkgs.{}", &chunk[1]),
10981100
"pkgs" => {
10991101
// Split by whitespace and format as a Nix list of package references
11001102
let items = chunk[1]

0 commit comments

Comments
 (0)