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

[FEATURE] setup scripts #116

Open
SIMULATAN opened this issue Mar 12, 2023 · 6 comments
Open

[FEATURE] setup scripts #116

SIMULATAN opened this issue Mar 12, 2023 · 6 comments

Comments

@SIMULATAN
Copy link

Is your feature request related to a problem? Please describe.
As my used programs grow larger, I need to run plenty of setup scripts. These can be rather cumbersome.
Another idea I had was to put some dotfiles that get updated way more regularly and thus would only clutter up your main dotfiles repo in another one. However, that requires additional effort.

Describe the solution you'd like
A setup configuration option for every package that allows you to run scripts when deployed for ex. for the first time (saved to cache)
This would also allow "script-only" packages that make it possible to configure things in a much more generic way (as in, you can not only symlink and copy whole files but also make scripts that configure applications via their CLI and such)

Describe alternatives you've considered
Have pre and post deploy hooks with package granularity

If we can come up with a concept that we're happy with I'd be happy to try and implement this and make a PR.
You did say that handling system packages is out of scope, but I think this feature would allow the creation of bridges between dotter and external programs that can handle that or something completely else.

@SuperCuber
Copy link
Owner

SuperCuber commented Mar 22, 2023

I can see this being useful. Do you have a more specific idea of how this would look? And an example for how you would use it :)

@SIMULATAN
Copy link
Author

For me personally, an use case would be to separate my BetterDiscord configs into another repository since the frequent commits would just clutter up the main one.

In that case, I'd have the package be a command package that runs something like this
betterdiscord/setup.sh

git clone https://example.com/my-repo BetterDiscordConfigs
cd BetterDiscordConfigs
# run the binary in the main repo but with the config from the BD repo
# this is done because dotter handles symlinking wayyy better than I could do myself
../dotter deploy

The configuration could roughly look like this:
.dotter/global.toml

[betterdiscord.scripts]
setup = "./betterdiscord/setup.sh"

This would also allow to add further scripts like pre- and post deploy hooks on a per-package basis (which could be super useful) at a later point.

Another use case: patching existing files.
Some, like spicetify configs, are different for each system, yet, some properties are the same and should be handled by the dotfiles manager.
With this concept, you could save a diff file in the package directory and create a script that applies that patch to the right files.

@SuperCuber
Copy link
Owner

I like it. For implementation, would probably work to add packages top level key to cache.toml then diff selected vs existing using that, and that's how we know whether should run setup/cleanup script.

No need for complex "update/create/delete" infrastructure like for files IMO, can just write the current packages after a deploy to it.

Do we want templating support for the setup/teardown script? Then we need to render it similar to deploy scripts.

@JaydenElliott
Copy link

Any plans on this feature being added? I would love to be able to install the dotter binary on recently imaged linux boot, clone the dotfiles repo and have my entire setup complete.

Something like

[install]
- git
- nvim
- tmux:optional-release-version
- "http:custom-git-repository"

Which would check for the install before going ahead.

Awesome work on the repo btw

@iliekturtles
Copy link
Contributor

What I've done is add a script that is deployed by dotter and can run global setup steps. On a clean machine the idea is that you only need git and dotter and that dotter will essentially just copy configuration files without relying on anything else being installed. The generated script (I called it dotupdate) can then be run to finish setup and install other required applications.

global.toml:

[shell.files]
"shell/dotupdate" = "~/.local/bin/dotupdate"
  1. git clone ...
  2. dotter deploy
  3. dotupdate # shell restart required.

@social-anthrax
Copy link

Just to chime in, I've been using dotter for vscode's dev-container feature and it's been great so far. As part of that it has a set of file names that it will execute by default. I normally use this to simply install the plugin managers that my dotfiles use after running dotter, similarly to the post deploy hook.

The manager already has the feature for hooks, would be nice to have independent hooks for each package, especially if we could template them.

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

No branches or pull requests

5 participants