Get path to calling file (calls function)

Hi there. I have defined a reusable function that I plan to call from other files in other directories.

But I have assets that will be processed in the function (png files) in a directory next to the calling file.

I hope to avoid having to pass the entire relative path to this folder from the context of the library function. It does not “feel” right.

My structure looks something like this:


So if I had to pass in the path to the function, it would likely end up being something like ../../modules/apps/app-name/icons

Which I guess would work. I’m just looking to see if there is a better way.

Why not just have the function take iconPath argument, and then pass it ./icons in the calling-file.nix?

I just figured this out. I had tried it first, and had build errors.

The issue turned out to be that I had it quoted with “./icons.” So when it was processed in function, the path was messed up, and the quotes were in the path, and my files were not found.

I had just come back to update. :man_facepalming:

1 Like