I want to pick the package names from the settings file and populate a shell session using those packages. I run this flake using nix run --impure .
I think this problem and the above listed problem are equivalent. Removing the "ocamlPackages.z3", line from the JSON will successfully run this flake.
No worries. Note that the null there is the default if the thing can’t be looked up. Another good default is (throw "Cannot find ${packageName}") or something similar.
nix-repl> f = packageName: lib.attrByPath (lib.splitString "." packageName) (throw "Cannot find ${packageName}") pkgs
nix-repl> f "python312Packages.grip"
«derivation /nix/store/y62ck6lif4njn7bv5dxd4gn2p81w1c60-python3.12-grip-4.6.1.drv»
nix-repl> f "python312Packages.grip2"
error:
… while calling the 'throw' builtin
at «string»:1:65:
1| packageName: lib.attrByPath (lib.splitString "." packageName) (throw "Cannot find ${packageName}") pkgs
| ^
error: Cannot find python312Packages.grip2