@@ -108,7 +108,7 @@ pub fn write_flake(
108108 //
109109 ////todo: does rust even need to be a special case?
110110 add_jupyter_kernels (
111- & parsed_config,
111+ parsed_config,
112112 & mut definitions,
113113 & mut nixpkgs_pkgs,
114114 & mut rust_extensions,
@@ -207,7 +207,7 @@ pub fn write_flake(
207207 & flake_filename,
208208 flake_dir,
209209 ) ?;
210- res = res | python_locks_changed;
210+ res |= python_locks_changed;
211211
212212 run_git_add ( & git_tracked_files, flake_dir) ?;
213213 run_git_commit ( flake_dir) ?; //after nix 2.23 we will need to commit the flake, possibly. At
@@ -293,7 +293,7 @@ fn insert_allow_unfree(
293293 "\" %PERMITTED_INSECURE_PACKAGES%\" " ,
294294 & ( permitted_insecure_packages
295295 . as_ref ( )
296- . map_or_else ( || String :: new ( ) , |x| x. join ( " " ) ) ) ,
296+ . map_or_else ( String :: new, |x| x. join ( " " ) ) ) ,
297297 )
298298}
299299
@@ -304,18 +304,14 @@ fn add_jupyter_kernels(
304304 rust_extensions : & mut Vec < String > ,
305305) {
306306 let mut jupyter_kernels = String :: new ( ) ;
307- let jupyter_included = parsed_config
308- . python
309- . as_ref ( )
310- . map ( |p| {
311- p. packages
312- . iter ( )
313- . any ( |( k, _) | k == "jupyter" || k == "notebook" || k == "jupyterlab" )
314- } )
315- . unwrap_or ( false ) ;
307+ let jupyter_included = parsed_config. python . as_ref ( ) . is_some_and ( |p| {
308+ p. packages
309+ . iter ( )
310+ . any ( |( k, _) | k == "jupyter" || k == "notebook" || k == "jupyterlab" )
311+ } ) ;
316312 if let Some ( r) = & parsed_config. r {
317313 // install R kernel
318- if jupyter_included && r. packages . iter ( ) . any ( |x| x == "IRkernel" ) && jupyter_included {
314+ if jupyter_included && r. packages . iter ( ) . any ( |x| x == "IRkernel" ) {
319315 jupyter_kernels. push_str (
320316 "
321317 mkdir $out/share/jupyter/kernels/R
@@ -347,12 +343,13 @@ fn add_jupyter_kernels(
347343 . to_string ( )
348344 + & jupyter_kernels;
349345 }
350- if jupyter_included && !jupyter_kernels. is_empty ( ) {
346+ if jupyter_included && !jupyter_kernels. is_empty ( ) {
351347 definitions. insert (
352348 "zzz_jupyter_kernel_drv" . to_string ( ) ,
353349 "pkgs.runCommand \" anysnake2-jupyter-kernels\" {} ''
354350 mkdir -p $out/share/jupyter/kernels
355- " . to_string ( )
351+ "
352+ . to_string ( )
356353 + & jupyter_kernels
357354 + "''" ,
358355 ) ;
@@ -534,8 +531,7 @@ fn copy_for_poetry(
534531) -> Result < String > {
535532 let pre_poetry_patch_sha = pre_poetry_patch
536533 . as_ref ( )
537- . map ( |x| sha256:: digest ( x) )
538- . unwrap_or_else ( || "None" . to_string ( ) ) ;
534+ . map_or_else ( || "None" . to_string ( ) , sha256:: digest) ;
539535
540536 let target_path = pyproject_toml_path
541537 . parent ( )
@@ -1131,6 +1127,7 @@ fn format_poetry_build_input_overrides(
11311127}
11321128
11331129#[ allow( clippy:: too_many_arguments) ]
1130+ #[ allow( clippy:: too_many_lines) ]
11341131fn add_python (
11351132 parsed_config : & mut config:: TofuConfigToml ,
11361133 inputs : & mut Vec < InputFlake > ,
@@ -1148,9 +1145,9 @@ fn add_python(
11481145 match & mut parsed_config. python {
11491146 Some ( python) => {
11501147 let original_pyproject_toml =
1151- ex:: fs:: read_to_string ( pyproject_toml_path) . unwrap_or_else ( |_| "" . to_string ( ) ) ;
1148+ ex:: fs:: read_to_string ( pyproject_toml_path) . unwrap_or_else ( |_| String :: new ( ) ) ;
11521149 let original_poetry_lock =
1153- ex:: fs:: read_to_string ( poetry_lock_path) . unwrap_or_else ( |_| "" . to_string ( ) ) ;
1150+ ex:: fs:: read_to_string ( poetry_lock_path) . unwrap_or_else ( |_| String :: new ( ) ) ;
11541151
11551152 if !Regex :: new ( r"^\d+\.\d+$" ) . unwrap ( ) . is_match ( & python. version ) {
11561153 bail ! (
@@ -1255,9 +1252,9 @@ fn add_python(
12551252 git_tracked_files. push ( "poetry_rewritten/poetry.lock" . to_string ( ) ) ;
12561253 git_tracked_files. push ( "poetry_rewritten/pyproject.toml" . to_string ( ) ) ;
12571254 let new_pyproject_toml =
1258- ex:: fs:: read_to_string ( pyproject_toml_path) . unwrap_or_else ( |_| "" . to_string ( ) ) ;
1255+ ex:: fs:: read_to_string ( pyproject_toml_path) . unwrap_or_else ( |_| String :: new ( ) ) ;
12591256 let new_poetry_lock =
1260- ex:: fs:: read_to_string ( poetry_lock_path) . unwrap_or_else ( |_| "" . to_string ( ) ) ;
1257+ ex:: fs:: read_to_string ( poetry_lock_path) . unwrap_or_else ( |_| String :: new ( ) ) ;
12611258 if new_pyproject_toml != original_pyproject_toml
12621259 || new_poetry_lock != original_poetry_lock
12631260 {
0 commit comments