/dotfiles

Gabor Udvari's dotfiles

Primary LanguageShell

Gábor Udvari’s dotfiles

All the dotfiles are maintained in org-mode files as literate configuration. This was done in the hope that the different snippets can be understood and copied separately regardless of your own dotfiles solution. Feel free to browse through the different files and use whatever you like.

Installation

You can compile the whole config by running make in the repository. The Makefile will extract all the actual configuration files first, and then it will do a guix reconfigure based on the target. If guix is not found, then it will try to link the config files with stow or chezmoi. You can find more explanation regarding these two steps below.

0. Requirements

For installation you will need make and emacs.

Windows

Here are some steps to be able to bootstrap the above tools:

  1. Download the RefreshEnv.cmd from the Chocolatey Project to make editing the PATH variable quicker: https://github.com/chocolatey/choco/blob/stable/src/chocolatey.resources/redirects/RefreshEnv.cmd
  2. Download Zstd from the official repository, so that we can uncompress Msys2 packages: https://github.com/facebook/zstd/releases/latest
  3. Add the Zstd folder to your users environment variables. Press Windows+R, and launch the following command to open up the environment variable editing window:
    rundll32.exe sysdm.cpl,EditEnvironmentVariables
        

    Once you added it, use the RefreshEnv.cmd from step 2 to update the variables.

From this point onwards you have two options, either use MSYS2 or Cygwin packages. The difference between the two is that Cygwin aims to be an environment to simulate Unix, while MSYS2 packages are native Windows applications. A practical example of this is that the Cygwin packaged tmux only works if you launch it from the Cygwin packaged bash, but not from the MSYS2 packaged bash. Also Git for Windows is based on MSYS2 as well, so you might already have it installed.

MSYS2

  1. Save time and effort by installing Git for Windows. This will get you a good base and some additional packages. https://gitforwindows.org/
  2. Download the Make package with this command, all the dependencies are covered with Git for Windows:

    NOTE: there is a bug in curl 8.8.0, the below command will fail with an error message. Curl 8.7 and 8.9 are not affected. curl/curl#13845

    curl -L -O -w '%{filename_effective}' https://mirror.msys2.org/msys/x86_64/make-4.4.1-2-x86_64.pkg.tar.zst | xargs tar -C ~/.local --zstd -xvf
        
  3. Download the Rsync packages with the following commands, all the other dependencies are covered with Git for Windows:
    curl -L -O -w '%{filename_effective}' https://mirror.msys2.org/msys/x86_64/rsync-3.3.0-1-x86_64.pkg.tar.zst | xargs tar -C ~/.local --zstd -xvf
    curl -L -O -w '%{filename_effective}' https://mirror.msys2.org/msys/x86_64/libxxhash-0.8.2-1-x86_64.pkg.tar.zst | xargs tar -C ~/.local --zstd -xvf
        

Cygwin

Download and install the Cygwin, Gettext, Make packages with these commands:

mkdir -p ~/.local
cd "$(mktemp -d)"
export MIRROR='https://mirror.accum.se/mirror/cygwin/x86_64/release'
curl -L -O -w '%{filename_effective}' "$MIRROR"/cygwin/cygwin-3.6.0-0.115.g579064bf4d40.tar.xz | xargs tar -C ~/.local -xvJf
curl -L -O -w '%{filename_effective}' "$MIRROR"/gcc/libgcc1/libgcc1-13.2.1+20240203-0.1.tar.zst | xargs tar -C ~/.local --zstd -xvf
curl -L -O -w '%{filename_effective}' "$MIRROR"/zstd/zstd-1.5.6-1.tar.zst | xargs tar -C ~/.local --zstd -xvf
curl -L -O -w '%{filename_effective}' "$MIRROR"/zlib/zlib-1.3.1-1.tar.zst| xargs tar -C ~/.local --zstd -xvf
curl -L -O -w '%{filename_effective}' "$MIRROR"/libiconv/libiconv2/libiconv2-1.17-1.tar.xz | xargs tar -C ~/.local -xvJf
curl -L -O -w '%{filename_effective}' "$MIRROR"/gettext/libintl8/libintl8-0.22.4-1.tar.xz | xargs tar -C ~/.local -xvJf
curl -L -O -w '%{filename_effective}' "$MIRROR"/make/make-4.4.1-2.tar.xz | xargs tar -C ~/.local -xvJf

curl -L -O -w '%{filename_effective}' "$MIRROR"/libxcrypt/libcrypt2/libcrypt2-4.4.20-1.tar.xz | xargs tar -C ~/.local -xvJf
curl -L -O -w '%{filename_effective}' "$MIRROR"/libffi/libffi8/libffi8-3.4.6-1.tar.xz | xargs tar -C ~/.local -xvJf
curl -L -O -w '%{filename_effective}' "$MIRROR"/libgc/libgc1/libgc1-8.2.6-1.tar.xz | xargs tar -C ~/.local -xvJf
curl -L -O -w '%{filename_effective}' "$MIRROR"/gmp/libgmp10/libgmp10-6.3.0-1.tar.zst | xargs tar -C ~/.local --zstd -xvf
curl -L -O -w '%{filename_effective}' "$MIRROR"/libunistring/libunistring5/libunistring5-1.2-1.tar.xz | xargs tar -C ~/.local -xvJf
curl -L -O -w '%{filename_effective}' "$MIRROR"/guile3.0/libguile3.0_1/libguile3.0_1-3.0.9-3.tar.xz | xargs tar -C ~/.local -xvJf

Linux

If you already have guix installed on your system, then you can launch a shell with all of the required libraries with the following command:

guix shell --search-paths --manifest=manifest.scm

The repository also has a direnv config file, if you also have that, then the above command will be run for you whenever you step into the directory of the repository.

1. Entanglement

You will need to start from an Emacs installation with org-mode configured. All the actual configuration files are stored in org-mode files and they need to be extracted into their own actual files.

emacs --batch --eval "(require 'org)" --eval '(org-babel-tangle-file "README.org")'

2.A Guix reconfiguration

Once the configuration files are extracted from the org-mode documentations, either the Guix Home or the Guix System needs to be reconfigured depending what you want to refresh.

guix home reconfigure -L build guix-home-config.scm
guix system reconfigure -L build guix-system-config.scm

2.B Stow linking

https://www.gnu.org/software/stow/

If guix cannot be found, then make will search for stow. If it finds stow, then it will link all the build/home files with it to the users actual home directory.

stow --no-folding --dir=./build --target ~/ home

Note: Stow can run under Windows, but the symbolic links created with Stow does not seem to work with the Windows version of Emacs. If you are on Windows use Rsync as described below.

2.C Rsync linking

If neither guix nor stow cannot be found, then make will search for rsync. If it finds rsync, then it will link all the build/home files to the users actual home directory.

rsync -avr build/home/ ~/

Windows notes

The default folder for Emacs configuration in Windows is the AppData/Roaming folder. The dotfiles configuration will move them inside the usual ~~/.config/emacs~ folder. Because of this you need to launch Emacs with the following command:

runemacs --init-directory %USERPROFILE%/.config/emacs

Other literate configs for inspiration

Concat the org files inside Emacs

Currently the final org file is created with cat, the order of the sections is kept due to the numbered filenames. There must be something better, eg. Algernon is using org-roam-list-files:

https://git.madhouse-project.org/algernon/infrastructure.org/src/branch/main/tools/entangle.el