kowainik / life-sync

🔄 Synchronize personal configs across multiple machines
https://kowainik.github.io/projects/life-sync
Mozilla Public License 2.0
21 stars 3 forks source link

Possibility to put `dotfiles` someplace other than $HOME #45

Open frontsideair opened 6 years ago

frontsideair commented 6 years ago

I just started using life-sync and it works like magic! I just keep all my git repos under ~/Code and seems like can't move dotfiles there.

I can work on this if you think it's not complicated. I have beginner to medium Haskell experience.

chshersh commented 6 years ago

I'm really happy you liked life-sync 😊

Yes, it uses hardcoded dotfiles location under ~/dotfiles. Making this directory configurable is a possible improvement for the package and I highly appreciate it! It requires to patch a lot of functions. But I think it worth it.

I guess best way to do this is to add lifeConfigurationRepoPath field to LifeConfiguration data type:

https://github.com/kowainik/life-sync/blob/c3dbae36614512c377839837dd28c3975789f20f/src/Life/Configuration.hs#L57-L60

Commands like life init can ask interactively about default location for dotfiles repository.

I think it's not complicated. So I really appreciate if you're going to work on this 🙏 It's just usual type of refactoring: moving something from hardcoded constant to runtime configuration. Haskell shines in such use-cases! Also, feel free to ask any questions about codebase. I will help gladly 🙂

frontsideair commented 6 years ago

Hi, I've started this task and it looks more complicated than I imagined.

My original use case was that I'd keep my dotfiles in ~/Code/dotfiles on macOS and ~/dotfiles on Linux. But life executable must know this path and thus keep it in the config, which you suggested. But then pulling someone's dotfiles would dictate where it would be stored.

A solution could be keeping the repo path in a separate file (e.g. ~/.life.local). While I don't like increasing the number of files for such a simple utility, I can't think of any other way for user experience.

Also, I noticed that making repo path dynamic eliminates one of the LifeExistence cases, specifically OnlyRepo case as we can't know anything about the repo if we don't have a life file. On the other hand, keeping this path in another file will keep OnlyRepo case, but add another case where we have a repo path but it's not actually there.

chshersh commented 6 years ago

@frontsideair I see, this issue indeed might be more complicated than it looks at first glance. @nixorn is currently working on supporting branch-based workflow (see PR #46). After this is implemented, it should become easier to make dotfiles path configurable in code. And also easier to maintain dotfiles repo on different machines. Basically, you should be able to store local path inside ~/.life file and then you can sync across multiple branches and multiple configurations. Though, the future interface is yet to be refined.