Skip to content

Commit

Permalink
Add idempotency
Browse files Browse the repository at this point in the history
  • Loading branch information
staticdev committed Jan 11, 2024
1 parent f810c2f commit e621ed2
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tasks/home-manager.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
---
- name: "Add home-manager channel"
- name: Check installation of Home Manager
ansible.builtin.command: home-manager --version
environment:
PATH: "{{ ansible_env.HOME + '/.nix-profile/bin:$PATH' }}"
register: home_manager_cmd
changed_when: false
ignore_errors: true

- name: Add Home Manager channel
when: home_manager_cmd is failed
ansible.builtin.command: "nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager"
environment:
PATH: "{{ ansible_env.HOME + '/.nix-profile/bin:$PATH' }}"
changed_when: false

- name: "Get channel updates"
- name: Get channel updates
when: home_manager_cmd is failed
ansible.builtin.command: "nix-channel --update"
environment:
PATH: "{{ ansible_env.HOME + '/.nix-profile/bin:$PATH' }}"
changed_when: false

- name: "Add Home Manager"
- name: Add Home Manager
when: home_manager_cmd is failed
ansible.builtin.command: "nix-shell '<home-manager>' -A install"
environment:
PATH: "{{ ansible_env.HOME + '/.nix-profile/bin:$PATH' }}"
Expand Down

0 comments on commit e621ed2

Please sign in to comment.