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

feat: Add read-source-state hook #3343

Merged
merged 2 commits into from
Nov 20, 2023
Merged

feat: Add read-source-state hook #3343

merged 2 commits into from
Nov 20, 2023

Conversation

twpayne
Copy link
Owner

@twpayne twpayne commented Nov 15, 2023

Refs #3342.

Work in progress. Small code change, big impact. Feedback appreciated.

@twpayne twpayne added work in progress Work in progress do not merge Do not merge labels Nov 15, 2023
@halostatue
Copy link
Collaborator

Seems like a potentially powerful change, as you say.

@twpayne twpayne marked this pull request as ready for review November 15, 2023 22:41
@twpayne
Copy link
Owner Author

twpayne commented Nov 15, 2023

@bradenhilton @nandalopes @felipecrs I would appreciate your input on this.

@felipecrs
Copy link
Contributor

I will carefully analyze and provide my feedback in some hours.

@twpayne
Copy link
Owner Author

twpayne commented Nov 15, 2023

No stress felipecrs and @halostatue I didn't mention because you're already in the conversation :)

@twpayne twpayne removed work in progress Work in progress do not merge Do not merge labels Nov 15, 2023
@felipecrs
Copy link
Contributor

I believe this is a nice change. It will also be useful to install tools required by output template calls, like curl or git.

@halostatue
Copy link
Collaborator

The code and documentation looks good. I think my main concern is that the commands need to be specified "full path". I'm not sure that there's a good workaround for this.

@bradenhilton
Copy link
Collaborator

Would the password manager part benefit from being more general instead? A password manager is just one of many potential prerequisites as @felipecrs pointed out.

Either way, this is great.

@twpayne
Copy link
Owner Author

twpayne commented Nov 18, 2023

Thank you all for the reviews!

I think my main concern is that the commands need to be specified "full path". I'm not sure that there's a good workaround for this.

Good point. It would be nice if the path to the read-source-state hook command was relative to the source directory.

One way I can think of doing this is by overriding the command (i.e. first checking for the command relative to the source state directory, and only afterwards falling back to the user's $PATH), but this falls foul of chezmoi's "the source state consists of only regular files and directories" principle as it would require the hook command to be executable in the source state.

Another way would be to use an explicit interpreter, something like:

[hooks.read-source-state.pre]
    command = "sh"
    args = ["-c", ".local/share/chezmoi/.install-password-manager.sh"]

Thoughts?

Would the password manager part benefit from being more general instead? A password manager is just one of many potential prerequisites as @felipecrs pointed out.

Yes, absolutely! I used the password manager example as it's a problem that I personally have (on a new machine I need to install and setup 1Password before I can deploy my dotfiles). It would be great to have some more examples of adding prerequisites.

@twpayne twpayne merged commit 7cd0423 into master Nov 20, 2023
18 checks passed
@twpayne twpayne deleted the read-source-state-hook branch November 20, 2023 21:18
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants