Skip to content

Commit

Permalink
feat: replace asdf with rtx (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
akikanellis authored Jan 1, 2024
1 parent 9264a74 commit 079f316
Show file tree
Hide file tree
Showing 17 changed files with 133 additions and 168 deletions.
1 change: 0 additions & 1 deletion .envrc

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fully automated, seamless CI/CD pipeline.
Install the following software

- [just](https://github.com/casey/just)
- [asdf](https://github.com/asdf-vm/asdf)
- [rtx](https://github.com/jdx/rtx)
- [![VirtualBox](docs/images/virtualbox.svg) VirtualBox](https://www.virtualbox.org)

### Usage
Expand Down
21 changes: 0 additions & 21 deletions ansible/roles/all/tasks/install-asdf.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
---
- name: Install asdf plugins
- name: Install rtx plugins
ansible.builtin.import_role:
name: common
tasks_from: asdf
tasks_from: rtx
vars:
asdf_plugins:
rtx_plugins:
- name: nodejs
- name: python

- name: Install tldr
- name: Install Node utilities
ansible.builtin.import_role:
name: common
tasks_from: npm
vars:
package_names: [tldr]

- name: Install pip_search
- name: Install Python utilities
ansible.builtin.import_role:
name: common
tasks_from: pip
vars:
package_names: pip_search
package_names: [pip_search]
17 changes: 17 additions & 0 deletions ansible/roles/all/tasks/install-rtx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- name: Install rtx
ansible.builtin.get_url:
url:
"https://github.com/jdx/rtx/releases/download/\
{{ rtx_version }}/\
rtx-\
{{ rtx_version }}-\
{{ ansible_system | lower }}-{{ rtx_architecture }}"
dest: /home/aki/.local/bin/rtx
owner: aki
group: aki
mode: 0700
register: result
retries: 10
delay: 2
until: result is success
8 changes: 4 additions & 4 deletions ansible/roles/all/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
- name: Setup ZSH
ansible.builtin.import_tasks: setup-zsh.yml

- name: Install asdf
ansible.builtin.import_tasks: install-asdf.yml
- name: Install rtx
ansible.builtin.import_tasks: install-rtx.yml

- name: Install asdf utilities
ansible.builtin.import_tasks: install-asdf-utilities.yml
- name: Install rtx utilities
ansible.builtin.import_tasks: install-rtx-utilities.yml
1 change: 0 additions & 1 deletion ansible/roles/all/tasks/setup-zsh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
antigen_theme:
name: robbyrussell
antigen_bundles:
- name: asdf
- name: aws
- name: brew
- name: dirhistory
Expand Down
1 change: 0 additions & 1 deletion ansible/roles/all/templates/users/aki/zsh/env.zsh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"

export _ZO_FZF_OPTS="--preview 'less {2}' --preview-window 'wrap'"

export DIRENV_LOG_FORMAT=""
export ASDF_GROOVY_DISABLE_JAVA_HOME_EXPORT=true
9 changes: 4 additions & 5 deletions ansible/roles/all/templates/users/aki/zsh/functions.zsh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ function update() {
echo "brew updated!"
fi

if command_exists asdf; then
echo "Updating asdf..."
asdf update
asdf plugin update --all
echo "asdf updated!"
if command_exists rtx; then
echo "Updating rtx..."
rtx upgrade --yes
echo "rtx updated!"
fi

if command_exists npm; then
Expand Down
6 changes: 3 additions & 3 deletions ansible/roles/all/templates/users/aki/zsh/zshrc.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ source ~/.zsh/options.zsh
source ~/.zsh/starship.zsh
source ~/.zsh/zoxide.zsh

# Created from `asdf direnv setup --shell zsh --version system`
# See: https://github.com/asdf-community/asdf-direnv#setup
source "${XDG_CONFIG_HOME:-$HOME/.config}/asdf-direnv/zshrc"
# Created from `echo 'eval "$(rtx activate zsh)"' >> "${ZDOTDIR-$HOME}/.zshrc"`
# See: https://rtx.jdx.dev/getting-started.html#zsh
eval "$(rtx activate zsh)"

source ~/.zsh/extra-zshrc-config.zsh
11 changes: 8 additions & 3 deletions ansible/roles/all/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
# renovate: datasource=github-releases depName=asdf-vm/asdf
asdf_version: v0.13.1

# renovate: datasource=github-releases depName=sharkdp/bat
bat_version: v0.24.0
architecture_to_bat_architecture:
Expand Down Expand Up @@ -70,6 +67,14 @@ architecture_to_lazygit_architecture:
lazygit_architecture: >-
{{ architecture_to_lazygit_architecture[ansible_architecture] }}
# renovate: datasource=github-releases depName=jdx/rtx
rtx_version: v2023.12.40
architecture_to_rtx_architecture:
x86_64: x64
armv7l: armv7
rtx_architecture: >-
{{ architecture_to_rtx_architecture[ansible_architecture] }}
# renovate: datasource=github-releases depName=ajeetdsouza/zoxide
zoxide_version: v0.9.2
architecture_to_zoxide_architecture:
Expand Down
110 changes: 0 additions & 110 deletions ansible/roles/common/tasks/asdf.yml

This file was deleted.

14 changes: 9 additions & 5 deletions ansible/roles/common/tasks/npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
- name: Install "aki" user global npm packages
become_user: aki
ansible.builtin.command:
cmd: >
zsh -c "source ~/.asdf/asdf.sh &&
direnv exec ~ npm install --global {{ item }}"
creates: "{{ npm_binaries_dir }}/{{ item }}"
loop: "{{ package_names }}"
cmd: >-
zsh -c
"rtx exec --
npm install --global {{ package_names | join(' ') }}"
register: npm_install
retries: 10
delay: 2
until: npm_install is success
changed_when: "'added' in npm_install.stdout"
62 changes: 62 additions & 0 deletions ansible/roles/common/tasks/rtx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
- name: Set plugin names
ansible.builtin.set_fact:
rtx_plugins_names: "{{ rtx_plugins | map(attribute='name') | list }}"

- name: Install "nodejs" rtx plugin dependencies
ansible.builtin.package:
name:
- dirmngr
- gpg
when: "'nodejs' in rtx_plugins_names"

# Needed by the python plugin due to pyenv
# See: https://github.com/pyenv/pyenv/wiki#suggested-build-environment
- name: Install "python" rtx plugin dependencies
ansible.builtin.package:
name:
- libbz2-dev
- libffi-dev
- liblzma-dev
- libncursesw5-dev
- libsqlite3-dev
- libssl-dev
- libxml2-dev
- libxmlsec1-dev
- llvm
- tk-dev
- xz-utils
- zlib1g-dev
when: "'python' in rtx_plugins_names"

- name: Install "aki" user rtx plugins
become_user: aki
ansible.builtin.command:
cmd: >-
zsh -c "
rtx use --global --yes
{{
rtx_plugins |
map(attribute='name') |
zip(rtx_plugins | map(attribute='version') | map('default', 'latest')) |
map('join', '@') |
join(' ')
}}"
register: rtx_install
retries: 10
delay: 2
until: rtx_install is success
changed_when: "'installed' in rtx_install.stdout"

- name: Discover "aki" user pip executable
become_user: aki
ansible.builtin.command:
cmd: zsh -c "rtx which pip"
register: which_pip
changed_when: false
when: "'python' in rtx_plugins_names"

- name: Set pip executable
ansible.builtin.set_fact:
pip_executable: "{{ which_pip.stdout }}"
when: "'python' in rtx_plugins_names"
22 changes: 17 additions & 5 deletions ansible/roles/workstations/tasks/install-dev-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
ansible.builtin.package:
name: vagrant

- name: Install "aki" user asdf dev tools
- name: Install "aki" user rtx dev tools
ansible.builtin.import_role:
name: common
tasks_from: asdf
tasks_from: rtx
vars:
asdf_plugins:
rtx_plugins:
- name: java
version: latest:temurin-18
version: temurin

- name: kotlin
- name: groovy
Expand Down Expand Up @@ -53,7 +53,19 @@
ansible.builtin.package:
name: terraform

- name: Install python dev tools
- name: Install Node dev tools
ansible.builtin.import_role:
name: common
tasks_from: npm
vars:
package_names:
- eslint
- nx
- prettier
- svgo
- yarn

- name: Install Python dev tools
ansible.builtin.import_role:
name: common
tasks_from: pip
Expand Down
2 changes: 1 addition & 1 deletion docs/DEVELOPERS_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test this project.
Install the following software

- [just](https://github.com/casey/just)
- [asdf](https://github.com/asdf-vm/asdf)
- [rtx](https://github.com/jdx/rtx)
- [![VirtualBox](images/virtualbox.svg) VirtualBox](https://www.virtualbox.org)

## Useful Commands
Expand Down
Loading

0 comments on commit 079f316

Please sign in to comment.