3
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
1 Over time, a Linux user may customize and configure his environment rather substantially.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
2 These modifications are stored in a collection of configuration files / data known as 'dotfiles' (because the first letter of many of them is '.').
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
3 For multiple reasons, it is very beneificial if you track, control and synchronise all of your personal dotfiles, a few example reasons include:
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
4 - Having an additional backup
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
5 - Being able to see their history, how they changed over time
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
6 - Being able to rollback changes if needed (I haven't needed this yet)
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
7 - Being able to use the same set of files accross multiple physical/virtual machines
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
8 - Being able to share you configuration with the world so people can learn from it just like you learn from other people's.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
9
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
10 However, there is not one single universal method for managing them, instead there are many tools and approaches that one can take.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
11 GitHub provides a decent list of programs [here](https://dotfiles.github.io/) but I intend to summarize the main approaches below.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
12 (It may be worth noting that while the methods may not be mutually exclusive, there is one 'main' approach/method per tool and that is what counts.)
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
13
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
14 1. Symlink-driven management involves moving the dotfiles away from their original location, instead creating symbolic links to one or more destinations.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
15 There are many ways/approaches of doing this, but the simplest is to just have a single directory be the destination for all the links.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
16 2. VC(Version Control)-driven management involves less management of actual dotfiles compared to the other two. Instead of copying or using symbolic links,
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
17 instead a version-control system is primarily used to track/manage dotfiles in groups. The original dotfiles are left in place, instead they can be treated
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
18 just like every other repository. There are multiple methods of implementing this approach with their own unique advantages and drawbacks.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
19 3. Configuration-driven management involves using explicit configuration file(s) to determine exactly what dotfiles are to be managed/tracked as well as how they are to be tracked among other things.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
20 The key difference between this method and the others is that rather than using interactive commands to manage and modify dotfiles, one or more configuration files are used.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
21 Typical formats for this information include YAML/JSON or a purpose-built configuration format. Typically but not exclusively uses symbolic links for dotfiles.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
22
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
23 I have been tracking my dotfiles for short-to-moderate period of time. I originally started when I read an article about using GNU Stow as the management tool.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
24 Stow has some features that make it just as useful for this as a dedicated too: It supports 'packages' so you can choose to install part of the dotfiles.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
25 It also doesn't make you specify specifically which files to symlink, it just symlinks the entire package.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
26 However, it's definitely not perfect: Symlinks can be overwritten, Moving dotfiles and replicating directory structures sucked, and you could only manage operations from the right directory.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
27 (I could also only easily have 1 VCS repo, which effectively meant private dotfiles couldn't be tracked)
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
28
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
29 One day, while inspecting my ~/dotfiles I noticed that the .git directory was missing. I could've seen this as a disaster, but I didn't.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
30 I had been thinking about migrating away from Stow for a while, but I never actually did anything - so I took this opportunity.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
31 After some reading/googling, I had made the decision to use `mr` and `vcsh`.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
32 `vcsh` would provide each individual repository, public and private while `mr` would be used for higher-level tasks.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
33 There are multiple guides to this pair of tools, such as:
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
34
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
35 * [This very short post on vcsh & mr](https://sumancluster.wordpress.com/2015/05/29/managing-dotfiles-using-vcsh-and-mr/)
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
36 * [This one which links to a more in-depth tutorial but also takes a look at the internals](https://www.kunxi.org/blog/2014/02/manage-dotfiles-using-vcsh-and-mr/)
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
37 * [This very useful and detailed one](http://srijanshetty.in/technical/vcsh-mr-dotfiles-nirvana/)
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
38
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
39 When I was migrating, I particularly found the latter link to be rather useful due to the detailed explanations of multiple common tasks.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
40 However, should you not want to read any of the above links I will attempt to give an overview of how it works in practice.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
41
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
42 # Creating a new repository
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
43
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
44 1. Clone/Initialize the local vcsh repository
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
45 2. Update the myrepos(mr) configuration to include that repository
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
46 3. Add the wanted stuff to the vcsh repository
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
47 4. Write/generate a .gitignore and modify as needed
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
48 5. Commit to the vcsh repository and push both sets of changes as needed.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
49
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
50 # Updating an existing repository
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
51
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
52 1. You can prefix git operations with vcsh and then the repo name to perform them on the repository.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
53 2. Alternatively, use 'vcsh enter' to go into an environment where git can be used normally.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
54
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
55 # Updating *all* the repositories
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
56
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
57 1. Use `mr up` and let myrepos do the job it was designed to do.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
58
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
59 # Bootstrapping the dotfiles
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
60 (presuming git is installed. If not, install it.)
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
61
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
62 1. Install myrepos and vcsh. If there's no distribution package, a manual install is easy (they're just standalone scripts)
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
63 2. Obtain your myrepos configuration.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
64 3. Use `mr up` and let myrepos obtain all your repositories as needed.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
65
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
66 If you think the above workflow looks interesting, I recommend you have a nice read of the above links - especially the last one
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
67 as I found it very useful. However, I have not moved my entire collection of dotfiles over and yet I still have some interesting problems/caveats to tackle.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
68
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
69 Firstly, while using a (private) Git repository to track my SSH/GPG data is useful, certain files have special filesystem permissions which Git does not preserve. While this can be solved with a chmod or two, it may grow
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
70 to be more difficult if I need more of these files in the future - plus I might be able to automate it using mr's 'fixups' functionality.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
71
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
72 Secondly, this is more of an observation than a problem: I'm currently using an Apache-style configuration involving both *'available.d'* and *'config.d'*. This works and is flexible, but it'd be simpler to only have a single directory and have equivalent information be part of the configuration itself.
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
73
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
74 Thirdly, bootstrapping from a completely clean slate is rather complicated. Certain repositories may depend on others to work / be in the correct location. Then there's the problem of access to private repositories, perhaps HTTP(s) could be used to download SSH keys using pre-entered cached credentials? A similar but lesser problem exists with GPG. Public repositories have no issues with this - if need be, they can have the master remote be changed afterwards.s
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
75
|
Samuel Hodgkins <samuel.hodgkins@sky.com>
parents:
diff
changeset
|
76 Anyway, that's all for now. If and when I solve the above issues I'll make sure to explain and blog about each my solutions. Until then, I don't expect this to come up again.
|