# set up flatpak support
- name: system setup | tweaks | add flatpak support
  package:
    name: flatpak
    state: present
- name: system setup | tweaks | enable fedora-workstation-repositories  
  tags: packages,system,system-packages,workstation-packages
  package:
    name:
      - fedora-workstation-repositories
  when: ansible_distribution in ["Fedora"] 

- name: system setup | tweaks | enable frpm fusion
  shell: sudo dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
  when: ansible_distribution in ["Fedora"]

- name: system setup | tweaks | flatpak | add flathub remote
  tags: packages,flatpak,workstation-packages
  become_user: super_user

  flatpak_remote:
    name: flathub
    flatpakrepo_url: https://flathub.org/repo/flathub.flatpakrepo
    method: user
    state: present

# distro-specific tasks for arch
- name: system setup | tweaks | install xorg (archlinux)
  tags: distro,distro-setup,packages,system,system-packages,workstation-packages
  package:
    name: xorg-server
  when: ansible_distribution == "Archlinux"

- name: system setup | tweaks | install nvidia gpu packages (arch)
  tags: distro,distro-setup,packages,nvidia,system,system-packages,workstation-packages
  package:
    name:
      - nvidia
      - nvidia-lts
      - nvidia-utils
  when:
    - ansible_distribution == "Archlinux"
    - gpu is defined
    - gpu == "nvidia"

- name: system setup | tweaks | install vbox gpu packages (arch)
  tags: distro,distro-setup,packages,system,system-packages,vbox,workstation-packages
  package:
    name:
      - virtualbox-guest-utils
      - xf86-video-vmware
  when:
    - ansible_distribution == "Archlinux"
    - gpu is defined
    - gpu == "vbox"


# distro-specific tasks for ubuntu
- name: system setup | tweaks | disable apport in config on ubuntu-based hosts
  tags: distro,distro-setup,apport,ubuntu
  lineinfile:
    dest: /etc/default/apport
    regexp: "enabled="
    line: "enabled=0"
  failed_when: false
  when: ansible_distribution in ["Pop!_OS", "Ubuntu"]

- name: system setup | tweaks | disable and stop apport service on ubuntu-based hosts
  tags: distro,distro-setup,apport,ubuntu
  service:
    name: apport
    enabled: no
    state: stopped
  failed_when: false
  when: ansible_distribution in ["Pop!_OS", "Ubuntu"]
