---
- name: Install universal base packages
  pacman:
      name: "{{ base_packages }}"
      state: present
  tags:
    - packages

- name: Create pacman hook directory
  file: path=/etc/pacman.d/hooks
        state=directory
  tags:
    - packages

- name: Use all cores when compressing packages
  lineinfile:
    dest: /etc/makepkg.conf
    regexp: "^COMPRESSXZ"
    line: "COMPRESSXZ=(xz -c -z - --threads=0)"

- name: Create AUR directory
  file: path=/home/{{ user.name }}/{{ aur.dir }}
        state=directory
        owner={{ user.name }}
        group={{ user.group }}
  tags:
    - aur
    - packages

- name: Install cower
  aur: name=cower user={{ user.name }} skip_pgp=yes
  tags:
    - aur
    - packages

- name: Install AUR base packages
  aur:
    name: "{{ aur.packages }}"
    user: "{{ user.name }}"
  tags:
    - aur
    - packages

- name: Push pacman cache cleanup service
  copy: src=paccache.service dest=/etc/systemd/system/paccache.service
  notify:
    - reload systemd config
  tags:
    - packages

- name: Push pacman cache cleanup timer
  copy: src=paccache.timer dest=/etc/systemd/system/paccache.timer
  notify:
    - reload systemd config
    - restart paccache
  tags:
    - packages

- name: Enable and start pacman cache cleanup timer
  service: name=paccache.timer enabled=yes state=started
  tags:
    - packages
