Skip to content

Commit

Permalink
Support 0.93.0 changes to plugins (#17)
Browse files Browse the repository at this point in the history
* Support 0.93.0 changes to plugins
  • Loading branch information
Yethal authored May 1, 2024
1 parent 0cdb436 commit 5c19c1e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 24 deletions.
26 changes: 2 additions & 24 deletions tasks/configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,30 +98,8 @@
- install_configs == 'remote'
- missing_configs|length > 0

- name: Create plugins config file
ansible.builtin.file:
state: touch
access_time: preserve
modification_time: preserve
path: "{{ item.homedir }}/{{ nushell_config_path }}/plugin.nu"
owner: "{{ item.user }}"
group: "{{ user_groups[ansible_facts.getent_passwd[item.user][2]] if ansible_system == 'Linux' else 'staff' }}"
mode: "0644"
loop: "{{ home_dirs }}"
loop_control:
label: "{{ item.user }}"
when: install_plugins|bool

- name: Register all plugins
ansible.builtin.command:
argv:
- "{{ nushell_binary_path }}/nu"
- --plugin-config "{{ item[0].homedir }}/{{ nushell_config_path }}/plugin.nu"
- -c "register {{ nushell_binary_path }}/{{ item[1] }}"
loop: "{{ home_dirs | product(nu_plugins) }}"
loop_control:
label: "{{ item[0].user }} {{ item[1] }}"
changed_when: false
- name: Configure nushell plugins
ansible.builtin.include_tasks: plugins.yml
when: install_plugins|bool

- name: Add nushell to .profile
Expand Down
29 changes: 29 additions & 0 deletions tasks/plugins.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
- name: Set facts
ansible.builtin.set_fact:
plugin_file: "{{ 'plugin.msgpackz' if _nushell_version is version('0.93.0', '>=') else 'plugin.nu' }}"
plugin_command: "{{ 'plugin add' if _nushell_version is version('0.93.0', '>=') else 'register' }}"

- name: Create plugins config file
ansible.builtin.file:
state: touch
access_time: preserve
modification_time: preserve
path: "{{ item.homedir }}/{{ nushell_config_path }}/{{ plugin_file }}"
owner: "{{ item.user }}"
group: "{{ user_groups[ansible_facts.getent_passwd[item.user][2]] if ansible_system == 'Linux' else 'staff' }}"
mode: "0644"
loop: "{{ home_dirs }}"
loop_control:
label: "{{ item.user }}"

- name: Register all plugins
ansible.builtin.command:
argv:
- "{{ nushell_binary_path }}/nu"
- --plugin-config "{{ item[0].homedir }}/{{ nushell_config_path }}/{{ plugin_file }}"
- -c "{{ plugin_command }} {{ nushell_binary_path }}/{{ item[1] }}"
loop: "{{ home_dirs | product(nu_plugins) }}"
loop_control:
label: "{{ item[0].user }} {{ item[1] }}"
changed_when: false

0 comments on commit 5c19c1e

Please sign in to comment.