feat(role): Add package-specific global config files

Packages can now have a global (i.e. system-wide) config defined and
applied. If package is missing the config file is deleted. This is
helpful for example for Git where we want to define helpful aliases
for every logged in user and for tmux where every user should have
access to the tmux-resurrect session manager etc.
This commit is contained in:
2025-08-21 03:48:22 +02:00
parent 588bc932de
commit f122b06697
6 changed files with 143 additions and 20 deletions

View File

@@ -56,3 +56,46 @@ packages_linux_common_debian:
- 'netcat-openbsd'
- 'unattended-upgrades'
- 'xxd'
package_config:
- name: 'tmux'
global_config_file: '/etc/tmux.conf'
marker: 'sane defaults'
global_config: |
# Renumber windows when one is deleted
set-option -g renumber-windows on
# Enable mouse control (clickable windows, panes, resizable panes)
set -g mouse on
- name: 'git'
global_config_file: '/etc/gitconfig'
marker: 'sane defaults'
global_config: |
[alias]
# https://stackoverflow.com/a/30998048
# Find merge that contains a given commit
find-merge = "!sh -c 'commit=$0 && branch=${1:-HEAD} && (git rev-list $commit..$branch --ancestry-path | cat -n; git rev-list $commit..$branch --first-parent | cat -n) | sort -k2 -s | uniq -f1 -d | sort -n | tail -1 | cut -f2'"
# https://stackoverflow.com/a/30998048
# Show merge commit msg and other details of merge commit
# that contains a given commit
show-merge = "!sh -c 'merge=$(git find-merge $0 $1) && [ -n \"$merge\" ] && git show $merge'"
# https://stackoverflow.com/a/23508223
# Show all commits that are part of a merge commit
log-merge = "!f() { git log --stat \"$1^..$1\"; }; f"
tmux_global_config_file: '/etc/tmux.conf'
tmux_global_config_resurrect: |
# Auto-load tmux-resurrect
# prefix + Ctrl-s - save
# prefix + Ctrl-r - restore
run-shell /usr/share/tmux-resurrect/resurrect.tmux
# Restore pane content (not just running commands)
# This will e.g. show the last 'ls' output you did in a pane
set -g @resurrect-capture-pane-contents 'on'
# Restore a few additional processes beyond the conservative default of
# vi vim nvim emacs man less more tail top htop irssi weechat mutt
set -g @resurrect-processes 'btop journalctl ncdu watch'