diff --git a/README.md b/README.md index a82aac3..987e44c 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ The main switches live near the top of `vars.yml`: - `upgrade_system`: upgrade packages before provisioning - `install_virtualization`: install Fedora's libvirt virtualization group - `install_sqlcmd`: retain the Fedora repository's existing SQL Server CLI +- `install_jdtls`: install Java's JDT LS directly from Eclipse, without Mason ## Re-running diff --git a/setup.yml b/setup.yml index c00e51c..c344cda 100644 --- a/setup.yml +++ b/setup.yml @@ -28,8 +28,11 @@ - ansible.builtin.import_tasks: tasks/services.yml - ansible.builtin.import_tasks: tasks/tooling.yml - ansible.builtin.import_tasks: tasks/jdtls.yml + when: install_jdtls - ansible.builtin.import_tasks: tasks/sqlcmd.yml when: install_sqlcmd - ansible.builtin.import_tasks: tasks/zen.yml - ansible.builtin.import_tasks: tasks/dotfiles.yml - ansible.builtin.import_tasks: tasks/user_config.yml + - ansible.builtin.import_tasks: tasks/pcloud.yml + when: install_pcloud diff --git a/tasks/jdtls.yml b/tasks/jdtls.yml index 761792c..4c19811 100644 --- a/tasks/jdtls.yml +++ b/tasks/jdtls.yml @@ -1,57 +1,100 @@ --- -- name: Check for Eclipse JDT Language Server +- name: Check for JDT LS ansible.builtin.stat: - path: "{{ jdtls_install_dir }}/bin/jdtls" + path: "{{ jdtls_install_dir }}/plugins" become: false - register: jdtls_binary + register: jdtls_installed -- name: Create JDT LS installation directories +- name: Create JDT LS target directories ansible.builtin.file: path: "{{ item }}" state: directory - owner: "{{ user_name }}" mode: "0755" - become: false loop: - "{{ jdtls_install_dir }}" - - "{{ user_home }}/.local/bin" - -- name: Read the JDT LS milestone archive name - ansible.builtin.uri: - url: "{{ jdtls_base_url }}/latest.txt" - return_content: true + - "{{ jdtls_bin_dir }}" become: false - register: jdtls_latest - when: not jdtls_binary.stat.exists -- name: Download Eclipse JDT Language Server +- name: Download Eclipse JDT LS ansible.builtin.get_url: - url: "{{ jdtls_base_url }}/{{ jdtls_latest.content | trim }}" + url: "{{ jdtls_url }}" dest: "{{ jdtls_archive }}" mode: "0644" - checksum: "sha256:{{ jdtls_base_url }}/{{ jdtls_latest.content | trim }}.sha256" - become: false - when: not jdtls_binary.stat.exists + force: "{{ jdtls_force_update }}" + timeout: "{{ jdtls_download_timeout }}" + register: jdtls_download + until: jdtls_download is succeeded + retries: "{{ jdtls_download_retries }}" + delay: "{{ jdtls_download_delay }}" + when: jdtls_force_update or not jdtls_installed.stat.exists -- name: Extract Eclipse JDT Language Server +- name: Remove existing JDT LS install when forced + ansible.builtin.file: + path: "{{ jdtls_install_dir }}" + state: absent + become: false + when: jdtls_force_update and jdtls_installed.stat.exists + +- name: Recreate JDT LS install directory + ansible.builtin.file: + path: "{{ jdtls_install_dir }}" + state: directory + mode: "0755" + become: false + when: jdtls_force_update and jdtls_installed.stat.exists + +- name: Extract Eclipse JDT LS ansible.builtin.unarchive: src: "{{ jdtls_archive }}" dest: "{{ jdtls_install_dir }}" remote_src: true - creates: "{{ jdtls_install_dir }}/bin/jdtls" become: false - when: not jdtls_binary.stat.exists + when: jdtls_force_update or not jdtls_installed.stat.exists -- name: Link jdtls into the user's PATH +- name: Check for bundled JDT LS launcher + ansible.builtin.stat: + path: "{{ jdtls_install_dir }}/bin/jdtls" + become: false + register: jdtls_bundled_launcher + +- name: Link bundled JDT LS launcher onto the user PATH ansible.builtin.file: src: "{{ jdtls_install_dir }}/bin/jdtls" - dest: "{{ user_home }}/.local/bin/jdtls" + dest: "{{ jdtls_bin_dir }}/jdtls" state: link force: true become: false + when: jdtls_bundled_launcher.stat.exists + +- name: Create fallback JDT LS launcher + ansible.builtin.copy: + dest: "{{ jdtls_bin_dir }}/jdtls" + mode: "0755" + content: | + #!/bin/bash + set -euo pipefail + + JDTLS_HOME="{{ jdtls_install_dir }}" + LAUNCHER_JAR=$(find "$JDTLS_HOME/plugins" -name "org.eclipse.equinox.launcher_*.jar" | sort | tail -n 1) + + exec java \ + -Declipse.application=org.eclipse.jdt.ls.core.id1 \ + -Dosgi.bundles.defaultStartLevel=4 \ + -Declipse.product=org.eclipse.jdt.ls.core.product \ + -Dlog.protocol=true \ + -Dlog.level=ALL \ + -Xmx1G \ + --add-modules=ALL-SYSTEM \ + --add-opens java.base/java.util=ALL-UNNAMED \ + --add-opens java.base/java.lang=ALL-UNNAMED \ + -jar "$LAUNCHER_JAR" \ + -configuration "$JDTLS_HOME/config_linux" \ + -data "$PWD/.jdtls-workspace" \ + "$@" + become: false + when: not jdtls_bundled_launcher.stat.exists - name: Remove downloaded JDT LS archive ansible.builtin.file: path: "{{ jdtls_archive }}" state: absent - become: false diff --git a/tasks/pcloud.yml b/tasks/pcloud.yml new file mode 100644 index 0000000..d240dda --- /dev/null +++ b/tasks/pcloud.yml @@ -0,0 +1,39 @@ +--- +- name: Create pCloud install directory + ansible.builtin.file: + path: /opt/pcloud + state: directory + mode: "0755" + +- name: Download pCloud AppImage + ansible.builtin.get_url: + url: "{{ pcloud_appimage_url }}" + dest: /opt/pcloud/pCloud.AppImage + mode: "0755" + timeout: 300 + +- name: Link pCloud onto system PATH + ansible.builtin.file: + src: /opt/pcloud/pCloud.AppImage + dest: /usr/local/bin/pcloud + state: link + force: true + +- name: Ensure system desktop application directory exists + ansible.builtin.file: + path: /usr/local/share/applications + state: directory + mode: "0755" + +- name: Create pCloud desktop launcher + ansible.builtin.copy: + dest: /usr/local/share/applications/pcloud.desktop + mode: "0644" + content: | + [Desktop Entry] + Type=Application + Name=pCloud Drive + Comment=pCloud Drive desktop client + Exec=/usr/local/bin/pcloud + Terminal=false + Categories=Network;FileTransfer; diff --git a/tasks/tooling.yml b/tasks/tooling.yml index b3aeb29..769074f 100644 --- a/tasks/tooling.yml +++ b/tasks/tooling.yml @@ -83,22 +83,17 @@ become: false register: starship_binary -- name: Download the Starship installer +- name: Download Starship installer script ansible.builtin.get_url: url: https://starship.rs/install.sh - dest: /tmp/starship-install.sh - mode: "0755" + dest: /tmp/install_starship.sh + mode: '0755' when: not starship_binary.stat.exists -- name: Install Starship for the workstation user - ansible.builtin.command: - argv: - - /tmp/starship-install.sh - - --yes - - --bin-dir - - "{{ user_home }}/.local/bin" - become: false +- name: Run Starship installer + ansible.builtin.command: /tmp/install_starship.sh -y when: not starship_binary.stat.exists + become: true - name: Check for Bun ansible.builtin.stat: diff --git a/tasks/user_config.yml b/tasks/user_config.yml index 03b06e0..1574062 100644 --- a/tasks/user_config.yml +++ b/tasks/user_config.yml @@ -1,4 +1,54 @@ --- +- name: Ensure XDG config and wanted user directories exist + ansible.builtin.file: + path: "{{ item.path }}" + state: directory + owner: "{{ user_name }}" + mode: "{{ item.mode }}" + loop: + - { path: "{{ user_home }}/.config", mode: "0755" } + - { path: "{{ user_home }}/Downloads", mode: "0755" } + - { path: "{{ user_home }}/Pictures", mode: "0755" } + become: false + +- name: Disable automatic XDG user directory creation + ansible.builtin.copy: + dest: "{{ user_home }}/.config/user-dirs.conf" + owner: "{{ user_name }}" + mode: "0644" + content: | + enabled=False + become: false + +- name: Keep only Downloads and Pictures as real XDG user directories + ansible.builtin.copy: + dest: "{{ user_home }}/.config/user-dirs.dirs" + owner: "{{ user_name }}" + mode: "0644" + content: | + XDG_DESKTOP_DIR="$HOME" + XDG_DOCUMENTS_DIR="$HOME" + XDG_DOWNLOAD_DIR="$HOME/Downloads" + XDG_MUSIC_DIR="$HOME" + XDG_PICTURES_DIR="$HOME/Pictures" + XDG_PUBLICSHARE_DIR="$HOME" + XDG_TEMPLATES_DIR="$HOME" + XDG_VIDEOS_DIR="$HOME" + become: false + +- name: Remove unwanted empty XDG directories + ansible.builtin.file: + path: "{{ user_home }}/{{ item }}" + state: absent + loop: + - Desktop + - Documents + - Music + - Public + - Templates + - Videos + become: false + - name: Check for the Git signing public key ansible.builtin.stat: path: "{{ git_signing_key }}" diff --git a/vars.yml b/vars.yml index 94441b2..c6783ef 100644 --- a/vars.yml +++ b/vars.yml @@ -4,10 +4,14 @@ user_home: "{{ lookup('env', 'HOME') }}" dotfiles_dir: "{{ user_home }}/dotfiles" dotfiles_repo: https://codeberg.org/bartal-lsn/dotfiles.git dotfiles_ssh_repo: git@codeberg.org:bartal-lsn/dotfiles.git -jdtls_version: "1.60.0" -jdtls_base_url: "https://download.eclipse.org/jdtls/milestones/{{ jdtls_version }}" +jdtls_url: https://download.eclipse.org/jdtls/snapshots/jdt-language-server-latest.tar.gz jdtls_install_dir: "{{ user_home }}/.local/share/jdtls" +jdtls_bin_dir: "{{ user_home }}/.local/bin" jdtls_archive: /tmp/jdtls.tar.gz +jdtls_force_update: false +jdtls_download_timeout: 300 +jdtls_download_retries: 3 +jdtls_download_delay: 10 system_timezone: Atlantic/Faroe system_locale: en_US.UTF-8 @@ -17,6 +21,9 @@ keyboard_layout: fo upgrade_system: true install_virtualization: true install_sqlcmd: true +install_jdtls: true +install_pcloud: true +pcloud_appimage_url: "https://plon1.pcloud.com/cBZeyCak57Ztkt7yq7ZZZ8t965kZ2ZZec4ZkZ9KHBHZJgZCzZrLZeFZ94ZkLZ5LZWQZr4Z6YZrFZmLZyQZoTZtwII5ZsVYEJTHXlFSbr5cyP1riD5WTyYYV/pCloud.AppImage" fedora_packages: # Media and documents