@@ -886,6 +886,52 @@ impl Devenv {
886
886
fs:: create_dir_all ( & self . devenv_runtime )
887
887
. unwrap_or_else ( |_| panic ! ( "Failed to create {}" , self . devenv_runtime. display( ) ) ) ;
888
888
889
+ // Create cli-options.nix if there are CLI options
890
+ if !self . global_options . option . is_empty ( ) {
891
+ let mut cli_options = String :: from ( "{\n " ) ;
892
+
893
+ const SUPPORTED_TYPES : & [ & str ] = & [ "string" , "int" , "float" , "bool" , "path" ] ;
894
+
895
+ for chunk in self . global_options . option . chunks_exact ( 2 ) {
896
+ // Parse the path and type from the first value
897
+ let key_parts: Vec < & str > = chunk[ 0 ] . split ( ':' ) . collect ( ) ;
898
+ if key_parts. len ( ) < 2 {
899
+ panic ! ( "Invalid option format: '{}'. Must include type, e.g. 'languages.rust.version:string'. Supported types: {}" ,
900
+ chunk[ 0 ] , SUPPORTED_TYPES . join( ", " ) ) ;
901
+ }
902
+
903
+ let path = key_parts[ 0 ] ;
904
+ let type_name = key_parts[ 1 ] ;
905
+
906
+ // Format value based on type
907
+ let value = match type_name {
908
+ "string" => format ! ( "\" {}\" " , & chunk[ 1 ] ) ,
909
+ "int" => chunk[ 1 ] . clone ( ) ,
910
+ "float" => chunk[ 1 ] . clone ( ) ,
911
+ "bool" => chunk[ 1 ] . clone ( ) , // true/false will work directly in Nix
912
+ "path" => format ! ( "./{}" , & chunk[ 1 ] ) , // relative path
913
+ _ => panic ! (
914
+ "Unsupported type: '{}'. Supported types: {}" ,
915
+ type_name,
916
+ SUPPORTED_TYPES . join( ", " )
917
+ ) ,
918
+ } ;
919
+
920
+ cli_options. push_str ( & format ! ( " {} = {};\n " , path, value) ) ;
921
+ }
922
+
923
+ cli_options. push_str ( "}\n " ) ;
924
+
925
+ fs:: write ( self . devenv_dotfile . join ( "cli-options.nix" ) , cli_options)
926
+ . expect ( "Failed to write cli-options.nix" ) ;
927
+ } else {
928
+ // Remove the file if it exists but there are no CLI options
929
+ let cli_options_path = self . devenv_dotfile . join ( "cli-options.nix" ) ;
930
+ if cli_options_path. exists ( ) {
931
+ fs:: remove_file ( & cli_options_path) . expect ( "Failed to remove cli-options.nix" ) ;
932
+ }
933
+ }
934
+
889
935
// create flake.devenv.nix
890
936
let vars = indoc:: formatdoc!(
891
937
"version = \" {}\" ;
0 commit comments