Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[help] Using variables in config section #346

Closed
RayZ0rr opened this issue May 19, 2022 · 4 comments
Closed

[help] Using variables in config section #346

RayZ0rr opened this issue May 19, 2022 · 4 comments
Labels

Comments

@RayZ0rr
Copy link

RayZ0rr commented May 19, 2022

What I am trying to achieve
I have an environment variable in .bashrc like this:

export DOTDIR="/some/path/to/dotfiles"

I want to use it with my dotdrop config like this:

config:
  dotpath: "{{@@ env['DOTDIR'] @@}}/dotfiles"

But this environmental variable doesn't get evaluated,

Then I changed it like this:

variables:
  myDots: "gFolder"
config:
  dotpath: "{{@@ myDots @@}}/dotfiles"

But I get the error:

[ERR] config error: undefined variable: 'myDots' is undefined

Is it possible to use variables here?

@RayZ0rr RayZ0rr added the help label May 19, 2022
@deadc0de6
Copy link
Owner

No, unfortunately it is not possible to use variables in dotpath. A list of elements of the config where variables can be used is listed here. Can you tell me more on your use-case/need, maybe we can work something out if that's something you need.

I'm however surprised by the second error you get since I cannot reproduce it. Whenever I use a variable in dotpath then simply the variable is not expanded and file is not found. I'm guessing you have an issue in a different part of your config file.

@RayZ0rr
Copy link
Author

RayZ0rr commented May 19, 2022

Yes, the second error was a problem with my config.

For, the first one I just thought I can keep my config file anywhere and not on the same directory as config.yaml exists. I was initially planning to give it like this: dotpath: "{{@@ env['HOME'] @@}}/gitfolder" but this is not really a big problem. Actually this is not even a inconvenience so I rather not turn this into a feature. I am very happy with how dotdrop works and wouldn't want to risk it breaking from minor features like this.

@RayZ0rr RayZ0rr closed this as completed May 19, 2022
deadc0de6 added a commit that referenced this issue May 26, 2022
@deadc0de6
Copy link
Owner

@RayZ0rr I added support for templating the dotpath entry. The following would work:

config:
  dotpath: "{{@@ env['SOME_VAR'] @@}}"

or

config:
  dotpath: "{{@@ val @@}}"
variables:
  val: "/tmp/xyz"

This will be part of the next release

deadc0de6 added a commit that referenced this issue May 27, 2022
@deadc0de6
Copy link
Owner

@RayZ0rr this is now available in version v1.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants