This directory contains the code and scripts that must be separate from the literate configs, because they are needed to tangle the literate configs in the first place.
The Dockerfile defines an image that can be run to generate all the configs as a tar.gz archive. It must use the root of the dotfiles repository as the build context, i.e. from ../ relative to this directory!
cd ..
docker build -t docker.veracioux.me/dotfiles-generator -f bootstrap/Dockerfile .
docker run docker.veracioux.me/dotfiles-generator -u $USER
Run with --help
to see detailed usage.
(require 'ob-tangle)
(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(shell . t)
(python . t)))
Custom functions and tweaks:
(defun haris/prevent-annoying-messages ()
(require 'cl-lib)
(advice-add 'sh-set-shell :around
(lambda (orig-fun &rest args)
(cl-letf (((symbol-function 'message) #'ignore))
(apply orig-fun args))))
(setq python-indent-guess-indent-offset nil))
(haris/prevent-annoying-messages)
(defun haris/tangle-deps (subpath)
"Prefix 'subpath' with the directory where dependency install scripts are tangled"
(concat "/tmp/dependencies-" (user-login-name) "/" subpath))
(defun haris/tangle-home (&optional subpath)
"Prefix 'subpath' with the directory that is used as staging for /home/haris when tangling"
(concat "/tmp/tangle-" (user-login-name) "/" subpath))
(defun haris/tangle--file-non-interactively (file)
"Tangle a file non-interactively, disabling all evaluation prompts including
buffer-local variables."
(save-excursion
(let* ((org-confirm-babel-evaluate nil)
(enable-local-variables :all)
(enable-local-eval t)
(buffer (find-file file)))
(org-babel-tangle)
(kill-buffer buffer))))
(defun haris/tangle-all (&optional to-destination &key dotfiles-dir)
"Tangle all my dotfiles.
By default the files are tangled into a temporary location that can be obtained
using (haris/tangle-home).
Optional argument TO-DESTINATION can be used to tangle the files directly to the
home directory. Keyword argument DOTFILES-DIR can be used to specify an
alternative dotfiles directory to '~/.haris'."
(interactive)
(when to-destination (delete-directory (haris/tangle-home) t))
(let ((org-dotfiles-root (or dotfiles-dir "~/.haris")))
(dolist (file (cl-delete-if
(lambda (x) (string-match-p "^\\.#" x))
(append (directory-files-recursively
org-dotfiles-root
"\\.org$"
nil
;; Exclude hidden directories
(lambda (dir-name)
(string-match
"^[^\\.]"
(file-name-nondirectory dir-name)))))))
(message "Tangling file: %s" file)
(haris/tangle--file-non-interactively file)))
(when to-destination
(shell-command (concat "rsync -rvu --keep-dirlinks " (haris/tangle-home) " ~/"))))
The normal <<...>>
syntax for noweb references breaks shell blocks. So I allow
«...»
as an alternative syntax to prevent that.
(defun org-babel-noweb-wrap (&optional regexp)
(rx-to-string
`(and (or "<<" "«")
(group
(not (or " " "\t" "\n"))
(? (*? any) (not (or " " "\t" "\n"))))
(or ">>" "»"))))
- When I move all versioned dotfiles into
~/.haris
, I can remove the need to clone the repo inside the docker container.