dotfiles.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Dotfiles</title>
  6. <link rel="shortcut icon" href="/csh/favicon.ico" type="image/x-icon"/>
  7. <link rel="stylesheet" type="text/css" href="/csh/stylesheet.css"/>
  8. </head>
  9. <body>
  10. <header>
  11. <p><a href="/csh"><img src="/csh/homeicon" alt="csh"/></a></p>
  12. </header>
  13. <h1>Organizing Public and Private Dotfiles for GNU Stow and Public Version Control</h1>
  14. <p>
  15. I <em>suck</em> at backing up. For once, I'd like to be able to
  16. download all my important stuff, run a single command, and have
  17. everything up and running. I've
  18. seen <a href="https://dotfiles.github.io/">many dotfile management
  19. schemes</a>,
  20. including <a href="https://github.com/wking/dotfiles-framework">dotfiles.sh</a>
  21. and <a href="https://github.com/lra/mackup">Mackup</a>, but they all
  22. seem just a little bit over-engineered for my tastes. In general, I
  23. prefer
  24. the <a href="http://brandon.invergo.net/news/2012-05-26-using-gnu-stow-to-manage-your-dotfiles.html">Stow
  25. method</a>.</p>
  26. <p>
  27. The only problem with using GNU Stow for this is that I can't really
  28. keep private files separate, and I certainly can't keep passwords
  29. out of files that demand to keep them alongside all the intersting
  30. settings that are worth sharing. To solve this, I will keep a
  31. single Stow package for all private files, and
  32. a <abbr title="Comma-Separated Values">CSV</abbr> file containing
  33. key-vlaue pairs for all private strings, which be applied and
  34. reverted with a simple search-and-replace mechanism before each
  35. deployment and publication.</p>
  36. <p>
  37. This text should describe what's important to me, and how it will be
  38. structured in a backup.</p>
  39. <h2>What's Important</h2>
  40. <p>
  41. There are two categories of important things: public, and private.</p>
  42. <h3>Public</h3>
  43. <ul>
  44. <li>Bash configs</li>
  45. <li>Emacs configs</li>
  46. <li>Personal Emacs Lisp</li>
  47. <li>Personal shell scripts</li>
  48. <li>tmux config</li>
  49. <li>X resources</li>
  50. <li>Fonts</li>
  51. <li>Themes</li>
  52. </ul>
  53. <h3>Private</h3>
  54. <ul>
  55. <li><abbr title="Secure Shell">SSH</abbr> keys</li>
  56. <li><abbr title="GNU Privacy Guard">GPG</abbr> keys</li>
  57. <li>Password store, for <a href="https://www.passwordstore.org/"><samp>pass</samp></a></li>
  58. <li>Contacts</li>
  59. <li>Work records</li>
  60. </ul>
  61. <h2>The Layout</h2>
  62. <p>
  63. I scribbled a mockup of the layout of my dotfiles on paper last
  64. night. It now looks something like this:</p>
  65. <pre>
  66. dotfiles/
  67. emacs/
  68. .emacs
  69. git/
  70. .gitconfig
  71. ssh/
  72. .ssh/
  73. id_rsa.pub
  74. known_hosts
  75. private.tar.gz.gpg
  76. .gnupg/
  77. ...
  78. .password-store/
  79. calher/
  80. matrix/
  81. pass.gpg
  82. ...
  83. csh/
  84. bluehome/
  85. pass.gpg
  86. roaming-initiative/
  87. pass.gpg
  88. sdf/
  89. pass.gpg
  90. notabug/
  91. pass.gpg
  92. calRedditFLOSSyourJS/
  93. reddit/
  94. pass.gpg
  95. CharlieBrown/
  96. freenode/
  97. pass.gpg
  98. freepost/
  99. pass.gpg
  100. .ssh/
  101. id_rsa
  102. substitutions.csv
  103. sha256sum password hash,base64 password cleartext
  104. 0693a3a41b7bda5568f205cc000bff5f3bf917f65535b721ae273b3a956ea0b5,UGFzc3dvcmQxCg==
  105. </pre>
  106. <p>
  107. Perhaps the most peculiar item in this listing is the
  108. file <samp>substitutions.csv</samp>. This is a list of
  109. corresponding strings for a search-and-replace program to use when
  110. adding or removing private information to otherwise public files.
  111. For example, if I wanted to put the
  112. passphrase <samp>Password1</samp> in my <samp>.gitconfig</samp>, I
  113. would add the following line after the <samp>[sendemail]</samp>
  114. section.</p>
  115. <pre>
  116. smtppass = 0693a3a41b7bda5568f205cc000bff5f3bf917f65535b721ae273b3a956ea0b5
  117. </pre>
  118. <p>
  119. This would be put in the public copy of <samp>.gitconfig</samp>.
  120. After replacing all the strings and applying it to the running
  121. system, however, the same line would show the more legible
  122. passphrase, <samp>Password1</samp>.</p>
  123. <pre>
  124. smtppass = Password1
  125. </pre>
  126. <p>
  127. This should work with any file. I doubt many programs would need me
  128. to escape characters in passphrases.</p>
  129. <h2 id="deployment">Deployment</h2>
  130. <p>
  131. The <a href="#deployment">#deployment</a> of the files should be as
  132. simple as cloning the repo, stowing the packages into the home
  133. directory where they belong, and replacing all the private strings
  134. mentioned in <samp>substitutions.csv</samp>.</p>
  135. <pre>
  136. git clone https://notabug.org/csh/dotfiles
  137. cd dotfiles
  138. stow tmux bash emacs git ssh
  139. gpg -d private.tar.gz.gpg
  140. tar -xvf private.tar.gz
  141. stow private
  142. private/expose-strings
  143. </pre>
  144. <p>
  145. <samp>expose-strings</samp> searches every file in
  146. the <samp>dotfiles/</samp> directory for the first cell of a line
  147. in <samp>substitutions.csv</samp>, <samp>base64</samp>-decodes the
  148. second cell of a line in the file, and puts the result in place of
  149. every found instance of the contents of the first cell of a
  150. line.</p>
  151. <p>
  152. <samp>hide-strings</samp> will undo all of this, returning the
  153. hashes to their original places. It will be run before every commit
  154. and upload. Hopefully, version control will not notice.</p>
  155. <h2 id="publishing">Publishing</h2>
  156. <p>
  157. In order to do the <a href="#publishing">#publishing</a> of any new
  158. changes made in version control, and put them in public view on the
  159. Internet, we must ensure that <samp>private/</samp>
  160. and <samp>private.tar.gz</samp> are erased so they do not get
  161. tracked or committed. In addition, <samp>hide-strings</samp> must
  162. be run so that passwords don't show up in public files either. Only
  163. then can changes be committed and pushed to version control.</p>
  164. <p>
  165. An example shell script might look like the following.</p>
  166. <pre>
  167. #!/bin/sh
  168. cd ~/dotfiles/
  169. # Disconnect private/
  170. rm private.tar.gz private.tar.gz.gpg
  171. stow -d private
  172. # Update private/
  173. tar -cvzf private.tar.gz private
  174. gpg -c private.tar.gz
  175. # Purge everything
  176. ./private/hide-strings
  177. rm -r private/ private.tar.gz
  178. # Push
  179. # No git commit; do manually in Emacs VC/Bash beforehand
  180. git push
  181. </pre>
  182. <hr/>
  183. <footer>
  184. <p>Last updated: 2017-10-11 18:51:43 CDT.</p>
  185. <p>
  186. Copyright 2017 Caleb Herbert under the terms of the
  187. <a href="https://creativecommons.org/licenses/by/4.0/">Attribution
  188. 4.0 International</a> license.</p>
  189. </footer>
  190. </body>
  191. </html>