Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Home Manager #434

Merged
merged 3 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- Development: [Golang], [NodeJs] and [Python tools].
- IDEs: [VSCodium] and [Pycharm] installation.
- Browsers: [Firefox] ESR replacement with official PPA and configuration; and [Brave] installation.
- Package manager installation: [Nix].
- Package manager installation: [Nix] and [Home Manager].
- Packages intallation: apt, nix, snap, pip, npm, ruby gems.
- Replaces [LibreOffice] with [OnlyOffice].
- Assorted FOSS programs: [Cryptomator], [KeyPass], [OBS], [OpenRGB], [RClone], and [Signal] messenger installation.
Expand Down Expand Up @@ -194,6 +194,7 @@ This project was inspired by [@geerlingguy]'s [Mac Development Ansible Playbook]
[git]: https://git-scm.com/
[gnome]: https://www.gnome.org/
[golang]: https://go.dev/
[home manager]: https://github.com/nix-community/home-manager
[libreoffice]: https://www.libreoffice.org/
[nodejs]: https://nodejs.org/
[keypass]: https://keepass.info/
Expand Down
11 changes: 5 additions & 6 deletions default.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ installed_packages:
- podman # see https://github.com/NixOS/nixpkgs/issues/138423
- poedit

install_home_manager: true
nix_packages:
- name: kubectl
check_cmd: kubectl version --client
Expand Down Expand Up @@ -82,13 +83,11 @@ nodejs_version: "20.x"
## Python settings
python_developer: true
pyenv_python_versions:
- 3.12.0
- 3.11.4
- 3.10.12
- 3.12.1
- 3.11.7
pyenv_global:
- 3.12.0
- 3.11.4
- 3.10.12
- 3.12.1
- 3.11.7
pyenv_virtualenvs: []

# IDEs
Expand Down
4 changes: 4 additions & 0 deletions main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
ansible.builtin.include_tasks: tasks/packages.yml
when: install_packages

- name: Install Home Manager
ansible.builtin.include_tasks: tasks/home-manager.yml
when: install_home_manager

- name: Install zsh
ansible.builtin.include_tasks: tasks/zsh.yml
when: install_zsh
Expand Down
31 changes: 31 additions & 0 deletions tasks/home-manager.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
- 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
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
when: home_manager_cmd is failed
ansible.builtin.command: "nix-shell '<home-manager>' -A install"
environment:
PATH: "{{ ansible_env.HOME + '/.nix-profile/bin:$PATH' }}"
# workaround of https://github.com/nix-community/home-manager/issues/3944
USER: $(id -un)
changed_when: true