dotfiles/dot_config/packages/run_onchange_after_arch-packages.fish.tmpl

44 lines
1,000 B
Cheetah
Raw Normal View History

{{ if lookPath "yay" -}}
#!/usr/bin/env fish
{{ range (glob ".config/packages/arch?*") -}}
# {{ include (joinPath "dot_config/packages/" (base .)) | sha256sum }}
{{ end -}}
cd "$HOME/.config/packages/"
set file (\
find . -type f -iname "arch?*" -print0\
| xargs -0 ls -tr\
| tail -n 1\
| string sub -s 3\
)
cp $file arch
{{ range .packages.arch -}}
{{ range . -}}
sed -i '/{{ . }}/d' arch
{{ end -}}
{{ end -}}
if ! test "{{ .chezmoi.hostname }}" = "$file"
set_color yellow && echo "Package list has changed, reinstalling..."
yay -S --needed - <~/.config/packages/arch
{{ if eq .chezmoi.hostname "archgirlie" -}}
{{ range .packages.arch.archgirlie -}}
yay -S --needed {{ . }}
{{ end -}}
{{ else if eq .chezmoi.hostname "archbaby" -}}
{{ range .packages.arch.archbaby -}}
yay -S --needed {{ . }}
{{ end -}}
{{ end -}}
end
yay -Qeq >{{ joinPath .chezmoi.sourceDir "dot_config/packages" .chezmoi.hostname }}
cd "$HOME"
{{ end -}}