diff --git a/.chezmoi.toml.tmpl b/.chezmoi.toml.tmpl index 082a8e5..b6c6c00 100644 --- a/.chezmoi.toml.tmpl +++ b/.chezmoi.toml.tmpl @@ -6,6 +6,11 @@ {{- $editor := promptBoolOnce . "features.editor" "Do you want to install Neovim" true }} {{- $nix := promptBoolOnce . "features.editor" "Do you want to install the Nix package manager" true }} +{{- $paru := false -}} +{{ if eq .chezmoi.osRelease.id "arch" -}} + {{- $paru = promptBoolOnce . "features.editor" "Do you want to install the Paru package manager" true -}} +{{- end }} + [data] email = {{ $email | quote }} git_name = {{ $git_name | quote }} @@ -15,3 +20,4 @@ shell = {{ $shell }} git = {{ $git }} editor = {{ $editor }} nix = {{ $nix }} +paru = {{ $paru }} diff --git a/home/.chezmoiignore.tmpl b/home/.chezmoiignore.tmpl index b503499..e658e1e 100644 --- a/home/.chezmoiignore.tmpl +++ b/home/.chezmoiignore.tmpl @@ -14,3 +14,7 @@ {{- if not .features.nix }} .config/nix {{- end }} + +{{- if not .features.paru }} +.config/paru +{{- end }} diff --git a/home/private_dot_config/paru/paru.conf b/home/private_dot_config/paru/paru.conf new file mode 100644 index 0000000..c6bcfcb --- /dev/null +++ b/home/private_dot_config/paru/paru.conf @@ -0,0 +1,18 @@ +[options] +# Reverse sort order of search results +BottomUp + +# Remove makedeps unconditionally after install +RemoveMake + +# Refresh sudo timestamp to avoid sudo re-prompts +SudoLoop + +# Skip review of build files +SkipReview + +# Remove build files after install +CleanAfter + +# Show a menu to select packages during upgrades +UpgradeMenu diff --git a/setup-script/playbook.yaml b/setup-script/playbook.yaml index c1c70f1..a760661 100644 --- a/setup-script/playbook.yaml +++ b/setup-script/playbook.yaml @@ -31,3 +31,5 @@ when: features.editor == true - role: nix when: features.nix == true + - role: paru + when: chezmoi.osRelease.id == "arch" and features.paru == true diff --git a/setup-script/roles/paru/tasks/main.yml b/setup-script/roles/paru/tasks/main.yml new file mode 100644 index 0000000..9a073d5 --- /dev/null +++ b/setup-script/roles/paru/tasks/main.yml @@ -0,0 +1,50 @@ +- name: Ensure build prerequisites are present + become: true + ansible.builtin.pacman: + name: + - base-devel + - fakeroot + +- name: Create temporary dir for build + ansible.builtin.tempfile: + state: directory + suffix: paru + register: paru_tmp + +- name: Download the AUR snapshot + ansible.builtin.get_url: + url: "https://aur.archlinux.org/cgit/aur.git/snapshot/paru-bin.tar.gz" + dest: "{{ paru_tmp.path }}/paru-bin.tar.gz" + +- name: Extract the snapshot + ansible.builtin.unarchive: + src: "{{ paru_tmp.path }}/paru-bin.tar.gz" + dest: "{{ paru_tmp.path }}" + remote_src: true + +- name: Build the package (no install) + ansible.builtin.command: + cmd: makepkg --syncdeps --noconfirm + chdir: "{{ paru_tmp.path }}/paru-bin" + environment: + PKGDEST: "{{ paru_tmp.path }}/paru-bin" + +- name: Locate built package(s) + ansible.builtin.find: + paths: "{{ paru_tmp.path }}/paru-bin" + patterns: "*.pkg.tar.zst" + file_type: file + register: built_pkgs + +# Install with root, but OUTSIDE makepkg +- name: Install built package(s) + become: true + ansible.builtin.command: + cmd: "pacman -U --noconfirm {{ item.path }}" + creates: /usr/bin/paru + loop: "{{ built_pkgs.files }}" + +- name: Remove temporary directory + ansible.builtin.file: + path: "{{ paru_tmp.path }}" + state: absent