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 ghcr.io/veracioux/dotfiles -f bootstrap/Dockerfile .docker run ghcr.io/veracioux/dotfiles -u $USERRun with --help to see detailed usage.
(require 'use-package)
(require 'ob-tangle)
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(use-package yaml :ensure t :defer nil)
(use-package password-store :ensure t :defer nil)
(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(shell . t)
(python . t)))(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--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 (&key dotfiles-dir)
"Tangle all my dotfiles.
Keyword argument DOTFILES-DIR can be used to specify an
alternative dotfiles directory to '~/.haris'."
(interactive)
(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 and different worktrees
(lambda (dir-name)
(and
(string-match
"^[^\\.]"
(file-name-nondirectory dir-name))
(not
(string-match "^wt-" (file-name-nondirectory dir-name)))))))))
(message "Tangling file: %s" file)
(haris/tangle--file-non-interactively file))))
(defun haris/org-babel-expand-noweb-references (block-name)
"Expand noweb references in the org-babel code block named BLOCK-NAME
in the current buffer."
(interactive "sBlock name: ")
(save-excursion
(let ((marker (org-babel-find-named-block block-name)))
(unless marker
(error "No block named %s found" block-name))
(goto-char marker)
(let* ((info (org-babel-get-src-block-info 'light)))
(org-babel-expand-noweb-references info)))))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.