Setup on bare metal

This runbook sets up the dev environment on your laptop or desktop. Follow the Arch installation guide.

Packages

  1. Install base packages using pacman.

    sudo pacman -S --needed sudo git openssh chezmoi base-devel
    

    base-devel has the build tools that step 2 needs.

  2. Install yay, the AUR helper.

    git clone https://aur.archlinux.org/yay-bin.git
    cd yay-bin
    makepkg -si
    cd .. && rm -rf yay-bin
    

    yay is a package manager for the AUR. It takes pacman’s commands, and it installs AUR packages that pacman cannot see. 1Password and its CLI are in the AUR, so yay installs them.

Linger

  1. Enable linger for your user.

    sudo loginctl enable-linger $USER
    

    XDG_RUNTIME_DIR is the directory for your session’s runtime files. systemd-logind creates it at login, and sets the variable for your session. The path is /run/user/ plus your user ID, such as /run/user/1000 for the first user.

    Without linger, the directory does not exist after you log out. The agent socket is absent.

The SSH key

  1. Export the private key from the Devices/jdoe_id item on a different device.

  2. Paste the private key into the terminal on this machine.

    ( umask 077; cat > ~/.ssh/jdoe_id )
    

    Press Ctrl-D after the last line of the key.

  3. Set the file mode to 0600.

    chmod 600 ~/.ssh/jdoe_id
    

    The subshell prevents a change to umask in the parent shell. If you set umask without a subshell, the next git pull writes each file that it changes as 0600.

  4. Start the agent socket.

    systemctl --user start ssh-agent.socket
    
  5. Add the key to the agent.

    SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket" ssh-add ~/.ssh/jdoe_id
    

    The command prompts for the passphrase.

  6. Check the key with GitHub.

    ssh -T git@github.com
    

    The output contains Hi <user>!.

    Keep the copy on disk for a session where 1Password is not available. At each login, op-keys.service loads the key from 1Password into the agent.

Apply the dotfiles

  1. Run the chezmoi init command.

    chezmoi init --apply ssh://git@git.jdoe-site.com:2222/home/git/dotfiles.git
    

    The URL contains the port number and the user name. This form does not need ~/.ssh/config. The command prompts for your name, your email, and the font size. The answers are kept for this machine. For an unattended installation, add --promptString.

    The command installs the package groups. The first installation is long. The native: group contains the desktop, the Wayland stack, and the GPU drivers. After the installation, Hyprland starts when you log in on tty1.

The 1Password token

op-keys.service loads the key and the passphrase from 1Password at each login. It uses the DevMachine service account. The token is a credential, and chezmoi does not manage it.

  1. Create the token file.

    ( umask 077; mkdir -p ~/.config/op
      printf 'OP_SERVICE_ACCOUNT_TOKEN=%s\n' '<token>' > ~/.config/op/token.env )
    
  2. Apply the dotfiles again.

    chezmoi apply
    
  3. If the unit is not enabled, enable it manually.

    systemctl --user enable --now op-keys.service
    
  4. Check the agent.

    op-keys && ssh-add -l
    

    The output is one line that ends with jdoe_id.

tmux and Neovim

tmux runs every shell. ~/.bashrc contains exec tmux new-session. tmux opens session 0 for the first terminal and session 1 for the second. A session continues after you close its terminal.

  1. Start Neovim to install the treesitter parsers.

    nvim
    
  2. Quit Neovim.

    Type :q and press Enter.

Neovim is the editor for vi and vim. Its keys are in neovim. The shell keys are in terminal and workflow.

The desktop

  1. Log out.

  2. Log in on tty1. Hyprland starts.

    The other TTYs open a shell in tmux. If the desktop configuration is incorrect, use one of these TTYs to get a shell.

    Do not start Hyprland from inside tmux. The terminals of Hyprland get $TMUX and do not start tmux. tmux kill-server then stops the desktop.

    The keys are in desktop.

Editing the dotfiles

chezmoi manages each file in your home directory. chezmoi shows the commands to edit a file and to check for changes that are not applied.

Verification

  1. Open a file in the editor.

    nvim ~/.bashrc
    

    Neovim shows the file.

  2. Quit Neovim.

    Type :q and press Enter.

  3. List the tmux sessions.

    tmux ls
    

    The output shows session 0 and each session that you did not close.

  4. Check the key with GitHub.

    ssh -T git@github.com
    

    The output contains Hi <user>!.