nickel icon indicating copy to clipboard operation
nickel copied to clipboard

Add the possibility to create import file names dynamically

Open NicholasPini opened this issue 7 months ago • 3 comments

Is your feature request related to a problem? Please describe. I'm trying to build a Nickel file which contains info about a bunch of Python projects in a monorepo and it would be nice to be able to read the prproject.toml files into a Nickel record. The issue is that I already have a field which contains the path to the project, and this would cause repetition:

{
  project_path = "path/to/project"
  toml_content = import "path/to/project/pyproject.toml"
}

Describe the solution you'd like It would be nice if the string passed to the import keyword could be constructed at runtime, enabling something like this:

{
  project_path = "path/to/project"
  toml_content = import "%{project_path}/pyproject.toml"
}

Describe alternatives you've considered

  1. Repeat the path in two strings, which is a bit annoying and error prone.
  2. Extract the pyproject.toml into whatever script the Nickel file is fed into. Kind of defeats the purpose of using Nickel in the first place.

NicholasPini avatar May 11 '25 09:05 NicholasPini

Note: related or even duplicate of https://github.com/tweag/nickel/issues/1865

yannham avatar May 12 '25 08:05 yannham

Sorry, you're right. I'll let you decide if it makes sense to keep this issue open just to show my use case, or if it's just an hassle and it's better to close it.

NicholasPini avatar May 12 '25 17:05 NicholasPini

No worries, I just wanted to link to the other issue before I forget. I think we can keep this one open as well; I find the feature request to be formulated more clearly, so other people might find it before the oldest.

yannham avatar May 13 '25 12:05 yannham