From 14e4d4fe3e3726dbb800535eb80a56b979186313 Mon Sep 17 00:00:00 2001 From: Johannes Knopp Date: Sat, 6 Sep 2025 15:44:39 +0200 Subject: [PATCH] move most important config to ansible --- group_vars/all.yml | 129 +++++++---------- inventory | 2 +- playbook.yml | 135 +++--------------- .../nvim/files}/after/ftplugin/markdown.lua | 0 .../nvim/files}/after/ftplugin/scss.lua | 0 .../nvim/files}/after/ftplugin/typescript.lua | 0 .../nvim/files}/after/ftplugin/vim.lua | 0 {nvim => roles/nvim/files}/init.lua | 0 {nvim => roles/nvim/files}/lazy-lock.json | 0 .../nvim/files}/lua/config/core/init.lua | 0 .../nvim/files}/lua/config/core/keymaps.lua | 2 +- .../nvim/files}/lua/config/core/options.lua | 0 .../nvim/files}/lua/config/lazy.lua | 0 .../files}/lua/config/plugins/airline.lua# | 0 .../nvim/files}/lua/config/plugins/alpha.lua | 0 .../lua/config/plugins/auto-session.lua | 0 .../files}/lua/config/plugins/autopairs.lua | 0 .../files}/lua/config/plugins/bufdelete.lua | 0 .../files}/lua/config/plugins/bufferline.lua | 0 .../nvim/files}/lua/config/plugins/cmp.lua | 0 .../files}/lua/config/plugins/colorscheme.lua | 0 .../files}/lua/config/plugins/diffview.lua | 0 .../files}/lua/config/plugins/dressing.lua | 0 .../files}/lua/config/plugins/floaterm.lua | 0 .../files}/lua/config/plugins/flutter.lua | 0 .../nvim/files}/lua/config/plugins/init.lua | 0 .../files}/lua/config/plugins/lazygit.lua | 0 .../lua/config/plugins/lsp/lspconfig.lua | 0 .../files}/lua/config/plugins/lsp/mason.lua | 0 .../files}/lua/config/plugins/lsp/null-ls.lua | 0 .../lua/config/plugins/lsp/pyrightconfig.json | 0 .../files}/lua/config/plugins/lualine.lua | 0 .../files}/lua/config/plugins/nvim-tree.lua | 0 .../files}/lua/config/plugins/surround.lua | 0 .../files}/lua/config/plugins/telescope.lua | 0 .../lua/config/plugins/todo-comments.lua | 0 .../files}/lua/config/plugins/treesitter.lua | 0 .../lua/config/plugins/venv-selector.lua | 0 .../files}/lua/config/plugins/which-key.lua | 0 roles/nvim/tasks/main.yml | 12 ++ roles/system/tasks/main.yml | 20 +++ roles/zsh/files/.zshrc | 52 +++++++ {zsh => roles/zsh/files}/aliases.zsh | 0 {zsh => roles/zsh/files}/dev_env.zsh | 0 {zsh => roles/zsh/files}/hosts/personal.zsh | 0 {zsh => roles/zsh/files}/hosts/work.zsh | 0 {zsh => roles/zsh/files}/tools.zsh | 0 roles/zsh/tasks/main.yaml | 24 ++++ zsh/.zshrc | 130 ----------------- 49 files changed, 179 insertions(+), 327 deletions(-) rename {nvim => roles/nvim/files}/after/ftplugin/markdown.lua (100%) rename {nvim => roles/nvim/files}/after/ftplugin/scss.lua (100%) rename {nvim => roles/nvim/files}/after/ftplugin/typescript.lua (100%) rename {nvim => roles/nvim/files}/after/ftplugin/vim.lua (100%) rename {nvim => roles/nvim/files}/init.lua (100%) rename {nvim => roles/nvim/files}/lazy-lock.json (100%) rename {nvim => roles/nvim/files}/lua/config/core/init.lua (100%) rename {nvim => roles/nvim/files}/lua/config/core/keymaps.lua (93%) rename {nvim => roles/nvim/files}/lua/config/core/options.lua (100%) rename {nvim => roles/nvim/files}/lua/config/lazy.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/airline.lua# (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/alpha.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/auto-session.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/autopairs.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/bufdelete.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/bufferline.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/cmp.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/colorscheme.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/diffview.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/dressing.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/floaterm.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/flutter.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/init.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/lazygit.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/lsp/lspconfig.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/lsp/mason.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/lsp/null-ls.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/lsp/pyrightconfig.json (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/lualine.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/nvim-tree.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/surround.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/telescope.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/todo-comments.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/treesitter.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/venv-selector.lua (100%) rename {nvim => roles/nvim/files}/lua/config/plugins/which-key.lua (100%) create mode 100644 roles/nvim/tasks/main.yml create mode 100644 roles/system/tasks/main.yml create mode 100644 roles/zsh/files/.zshrc rename {zsh => roles/zsh/files}/aliases.zsh (100%) rename {zsh => roles/zsh/files}/dev_env.zsh (100%) rename {zsh => roles/zsh/files}/hosts/personal.zsh (100%) rename {zsh => roles/zsh/files}/hosts/work.zsh (100%) rename {zsh => roles/zsh/files}/tools.zsh (100%) create mode 100644 roles/zsh/tasks/main.yaml delete mode 100644 zsh/.zshrc diff --git a/group_vars/all.yml b/group_vars/all.yml index 1d46a73..427cc28 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -1,20 +1,19 @@ default_roles: # === Core System Tools (Recommended) === - system # Essential system configurations and tools - - fonts # Developer-friendly fonts (Nerd Fonts) + # - fonts # Developer-friendly fonts (Nerd Fonts) # === Development Core === - - git # Version control system - - neovim # Modern text editor (or use 'vim') - - tmux # Terminal multiplexer for session management - + # - git # Version control system + - nvim # Modern text editor (or use 'vim') + # - tmux # Terminal multiplexer for session management + # # === Shell Environment === - zsh # Modern shell with oh-my-zsh + # - ssh +temp: # === Development Languages === - - nvm # Node Version Manager - - npm # Node Package Manager - - go # Go programming language # - rust # Rust programming language # - ruby # Ruby programming language # - lua # Lua programming language @@ -22,81 +21,55 @@ default_roles: - docker # Container platform # === System Monitoring === - - btop # Modern system monitor (better than htop) - # - neofetch # System information display - # - nerdfetch # Alternative system info with ASCII art - # - ncdu # Disk usage analyzer # === Terminal Emulators === + - ghostty # - kitty # GPU-accelerated terminal # - warp # Modern terminal with AI features # === Productivity Tools === # - obsidian # Knowledge management and note-taking - # - raycast # macOS launcher and productivity tool - # - hammerspoon # macOS automation and window management - # - taskfile # Modern task runner (alternative to make) - # - tldr # Simplified command documentation - # - slides # Terminal-based presentation tool + +system_packages: + # Network + - curl + - wget + - rsync + - nmap + # - nslookup + # - dig - # === Communication & Media === - # - discord # Team communication - # - spotify # Music streaming - - # === Network & Remote Access === - # - ssh # SSH client configuration - # - sshfs # Mount remote filesystems via SSH - # - tmate # Terminal sharing for pair programming - - # === macOS Specific === - # - aldente # Battery charge limiter for macOS - - # === Linux Specific === - # - flatpak # Universal Linux package manager - # - nala # Better apt frontend for Ubuntu/Debian - - # === Browser Tools === - # - brave # Privacy-focused web browser - - # === Cloud & Infrastructure CLIs === - # - aws # Amazon Web Services CLI - # - azure # Microsoft Azure CLI - # - nomad # HashiCorp Nomad (alternative to Kubernetes) - - # === Container Alternatives === - # - orbstack # Docker Desktop alternative for macOS - - # === Additional Terminal Emulators === - # - alacritty # Cross-platform GPU-accelerated terminal - # - ghostty # Fast, feature-rich terminal emulator - - # === Development Tools === - # - just # Command runner (modern alternative to make) - # - goreleaser # Go application release automation - - # === Kubernetes Ecosystem === - # - kind # Kubernetes in Docker for local testing - # - kwctl # Kubernetes policy engine management - - # === Network & VPN Tools === - # - wireguard # Modern VPN solution - - # === Alternative Shells === - # - bash # Traditional bash shell configuration - # - pwsh # PowerShell for cross-platform scripting - # - zellij # Terminal workspace manager (alternative to tmux) - - # === Package Managers === - # - whalebrew # Homebrew but with Docker images - - # === Windows Specific === - # - winget # Windows package manager (Windows only) - - # === Fun Stuff === - # - asciiquarium # Animated ASCII aquarium for your terminal - - # === Security & Authentication === - # - 1password # 1Password CLI integration - - # === Network Analysis === - # - tshark # Command-line network protocol analyzer + # archive/compression + - unzip + - tar + + # text processing + - jq + - ripgrep + - fd + + # utilities + - btop + - which + # - fzf + - bat + - eza + - tealdeer + - neofetch + + # dev + - nvm + - go + - discord # Team communication + + +# TODO +aur_packages: + - autojump + - spotify + - qownnotes + - stripe-cli + - pgformatter-git + # - jetbrains-toolbox + +config_dir: "{{ ansible_facts.env.HOME }}/.config" diff --git a/inventory b/inventory index 13cfabe..fe31dc2 100644 --- a/inventory +++ b/inventory @@ -1,2 +1,2 @@ [local] -localhost ansible_connection=local +localhost ansible_connection=local ansible_user=johannes diff --git a/playbook.yml b/playbook.yml index a5c3ad3..da49a69 100644 --- a/playbook.yml +++ b/playbook.yml @@ -5,123 +5,24 @@ become: false vars: dotfiles_dir: "{{ ansible_env.HOME }}/dotfiles" - - tasks: - - name: Install packages with pacman + # roles: + # - zsh + + pre_tasks: + - name: Create btrfs snapshot before changes + shell: | + sudo btrfs subvolume snapsho / /.snapshots/before-dotfiles-$(date +%Y%m%d-%H%M%S) + tags: [snapshot] become: true - pacman: - name: - - neovim - - zsh - - git - - openssh - state: present + become_method: sudo - - name: Install oh-my-zsh from AUR - kewlfft.aur.aur: - name: oh-my-zsh-git - state: present - - - name: Create necessary directories - file: - path: "{{ item }}" - state: directory - mode: '0755' + tasks: + - name: Install enabled roles + ansible.builtin.include_role: + name: "{{ item }}" + apply: + tags: + - install loop: - - "{{ ansible_env.HOME }}/.config" - - "{{ ansible_env.HOME }}/.ssh" - - - name: Check if neovim config exists - stat: - path: "{{ dotfiles_dir }}/nvim" - register: nvim_config - - - name: Symlink neovim config - file: - src: "{{ dotfiles_dir }}/nvim" - dest: "{{ ansible_env.HOME }}/.config/nvim" - state: link - force: true - when: nvim_config.stat.exists - - - name: Check if zsh config exists - stat: - path: "{{ dotfiles_dir }}/zsh/.zshrc" - register: zsh_config - - - name: Symlink zsh config - file: - src: "{{ dotfiles_dir }}/zsh/.zshrc" - dest: "{{ ansible_env.HOME }}/.zshrc" - state: link - force: true - when: zsh_config.stat.exists - - - name: Change default shell to zsh - become: true - user: - name: "{{ ansible_env.USER }}" - shell: /usr/bin/zsh - - - name: Symlink SSH askpass config - file: - src: "{{ dotfiles_dir }}/ssh_askpass.conf" - dest: "{{ ansible_env.HOME }}/.ssh/askpass.conf" - state: link - force: true - when: zsh_config.stat.exists - - - name: Check if git config exists - stat: - path: "{{ dotfiles_dir }}/git/.gitconfig" - register: git_config - - - name: Symlink global git config - file: - src: "{{ dotfiles_dir }}/git/.gitconfig" - dest: "{{ ansible_env.HOME }}/.gitconfig" - state: link - force: true - when: git_config.stat.exists - - - name: Check if kde config exists - stat: - path: "{{ dotfiles_dir }}/kde" - register: kde_config - - - name: Find KDE config files in dotfiles - find: - paths: "{{ dotfiles_dir }}/kde" - patterns: "*" - file_type: file - register: kde_configs - when: kde_config.stat.exists - - - name: Symlink KDE config files - file: - src: "{{ item.path }}" - dest: "{{ ansible_env.HOME }}/.config/{{ item.path | basename }}" - state: link - force: true - loop: "{{ kde_configs.files }}" - when: kde_configs.files is defined - - - name: Install yay if not present (for AUR packages) - block: - - name: Check if yay is installed - command: which yay - register: yay_check - failed_when: false - changed_when: false - - - name: Install yay from AUR - become: true - shell: | - cd /tmp - git clone https://aur.archlinux.org/yay.git - cd yay - makepkg -si --noconfirm - cd .. - rm -rf yay - when: yay_check.rc != 0 - + "{{ default_roles }}" + # when: default_roles is defined diff --git a/nvim/after/ftplugin/markdown.lua b/roles/nvim/files/after/ftplugin/markdown.lua similarity index 100% rename from nvim/after/ftplugin/markdown.lua rename to roles/nvim/files/after/ftplugin/markdown.lua diff --git a/nvim/after/ftplugin/scss.lua b/roles/nvim/files/after/ftplugin/scss.lua similarity index 100% rename from nvim/after/ftplugin/scss.lua rename to roles/nvim/files/after/ftplugin/scss.lua diff --git a/nvim/after/ftplugin/typescript.lua b/roles/nvim/files/after/ftplugin/typescript.lua similarity index 100% rename from nvim/after/ftplugin/typescript.lua rename to roles/nvim/files/after/ftplugin/typescript.lua diff --git a/nvim/after/ftplugin/vim.lua b/roles/nvim/files/after/ftplugin/vim.lua similarity index 100% rename from nvim/after/ftplugin/vim.lua rename to roles/nvim/files/after/ftplugin/vim.lua diff --git a/nvim/init.lua b/roles/nvim/files/init.lua similarity index 100% rename from nvim/init.lua rename to roles/nvim/files/init.lua diff --git a/nvim/lazy-lock.json b/roles/nvim/files/lazy-lock.json similarity index 100% rename from nvim/lazy-lock.json rename to roles/nvim/files/lazy-lock.json diff --git a/nvim/lua/config/core/init.lua b/roles/nvim/files/lua/config/core/init.lua similarity index 100% rename from nvim/lua/config/core/init.lua rename to roles/nvim/files/lua/config/core/init.lua diff --git a/nvim/lua/config/core/keymaps.lua b/roles/nvim/files/lua/config/core/keymaps.lua similarity index 93% rename from nvim/lua/config/core/keymaps.lua rename to roles/nvim/files/lua/config/core/keymaps.lua index f739e66..c2c5ba3 100644 --- a/nvim/lua/config/core/keymaps.lua +++ b/roles/nvim/files/lua/config/core/keymaps.lua @@ -6,7 +6,7 @@ local opts = { noremap = true, silent = true } -- INSERT MODE -- map `ctrl + backspace` to delete previous word in insert mode -keymap.set('i', '', '', opts) +keymap.set('i', '', '', opts) -- map `ctrl + delete` to delete next word in insert mode keymap.set('i', '', 'dw', opts) diff --git a/nvim/lua/config/core/options.lua b/roles/nvim/files/lua/config/core/options.lua similarity index 100% rename from nvim/lua/config/core/options.lua rename to roles/nvim/files/lua/config/core/options.lua diff --git a/nvim/lua/config/lazy.lua b/roles/nvim/files/lua/config/lazy.lua similarity index 100% rename from nvim/lua/config/lazy.lua rename to roles/nvim/files/lua/config/lazy.lua diff --git a/nvim/lua/config/plugins/airline.lua# b/roles/nvim/files/lua/config/plugins/airline.lua# similarity index 100% rename from nvim/lua/config/plugins/airline.lua# rename to roles/nvim/files/lua/config/plugins/airline.lua# diff --git a/nvim/lua/config/plugins/alpha.lua b/roles/nvim/files/lua/config/plugins/alpha.lua similarity index 100% rename from nvim/lua/config/plugins/alpha.lua rename to roles/nvim/files/lua/config/plugins/alpha.lua diff --git a/nvim/lua/config/plugins/auto-session.lua b/roles/nvim/files/lua/config/plugins/auto-session.lua similarity index 100% rename from nvim/lua/config/plugins/auto-session.lua rename to roles/nvim/files/lua/config/plugins/auto-session.lua diff --git a/nvim/lua/config/plugins/autopairs.lua b/roles/nvim/files/lua/config/plugins/autopairs.lua similarity index 100% rename from nvim/lua/config/plugins/autopairs.lua rename to roles/nvim/files/lua/config/plugins/autopairs.lua diff --git a/nvim/lua/config/plugins/bufdelete.lua b/roles/nvim/files/lua/config/plugins/bufdelete.lua similarity index 100% rename from nvim/lua/config/plugins/bufdelete.lua rename to roles/nvim/files/lua/config/plugins/bufdelete.lua diff --git a/nvim/lua/config/plugins/bufferline.lua b/roles/nvim/files/lua/config/plugins/bufferline.lua similarity index 100% rename from nvim/lua/config/plugins/bufferline.lua rename to roles/nvim/files/lua/config/plugins/bufferline.lua diff --git a/nvim/lua/config/plugins/cmp.lua b/roles/nvim/files/lua/config/plugins/cmp.lua similarity index 100% rename from nvim/lua/config/plugins/cmp.lua rename to roles/nvim/files/lua/config/plugins/cmp.lua diff --git a/nvim/lua/config/plugins/colorscheme.lua b/roles/nvim/files/lua/config/plugins/colorscheme.lua similarity index 100% rename from nvim/lua/config/plugins/colorscheme.lua rename to roles/nvim/files/lua/config/plugins/colorscheme.lua diff --git a/nvim/lua/config/plugins/diffview.lua b/roles/nvim/files/lua/config/plugins/diffview.lua similarity index 100% rename from nvim/lua/config/plugins/diffview.lua rename to roles/nvim/files/lua/config/plugins/diffview.lua diff --git a/nvim/lua/config/plugins/dressing.lua b/roles/nvim/files/lua/config/plugins/dressing.lua similarity index 100% rename from nvim/lua/config/plugins/dressing.lua rename to roles/nvim/files/lua/config/plugins/dressing.lua diff --git a/nvim/lua/config/plugins/floaterm.lua b/roles/nvim/files/lua/config/plugins/floaterm.lua similarity index 100% rename from nvim/lua/config/plugins/floaterm.lua rename to roles/nvim/files/lua/config/plugins/floaterm.lua diff --git a/nvim/lua/config/plugins/flutter.lua b/roles/nvim/files/lua/config/plugins/flutter.lua similarity index 100% rename from nvim/lua/config/plugins/flutter.lua rename to roles/nvim/files/lua/config/plugins/flutter.lua diff --git a/nvim/lua/config/plugins/init.lua b/roles/nvim/files/lua/config/plugins/init.lua similarity index 100% rename from nvim/lua/config/plugins/init.lua rename to roles/nvim/files/lua/config/plugins/init.lua diff --git a/nvim/lua/config/plugins/lazygit.lua b/roles/nvim/files/lua/config/plugins/lazygit.lua similarity index 100% rename from nvim/lua/config/plugins/lazygit.lua rename to roles/nvim/files/lua/config/plugins/lazygit.lua diff --git a/nvim/lua/config/plugins/lsp/lspconfig.lua b/roles/nvim/files/lua/config/plugins/lsp/lspconfig.lua similarity index 100% rename from nvim/lua/config/plugins/lsp/lspconfig.lua rename to roles/nvim/files/lua/config/plugins/lsp/lspconfig.lua diff --git a/nvim/lua/config/plugins/lsp/mason.lua b/roles/nvim/files/lua/config/plugins/lsp/mason.lua similarity index 100% rename from nvim/lua/config/plugins/lsp/mason.lua rename to roles/nvim/files/lua/config/plugins/lsp/mason.lua diff --git a/nvim/lua/config/plugins/lsp/null-ls.lua b/roles/nvim/files/lua/config/plugins/lsp/null-ls.lua similarity index 100% rename from nvim/lua/config/plugins/lsp/null-ls.lua rename to roles/nvim/files/lua/config/plugins/lsp/null-ls.lua diff --git a/nvim/lua/config/plugins/lsp/pyrightconfig.json b/roles/nvim/files/lua/config/plugins/lsp/pyrightconfig.json similarity index 100% rename from nvim/lua/config/plugins/lsp/pyrightconfig.json rename to roles/nvim/files/lua/config/plugins/lsp/pyrightconfig.json diff --git a/nvim/lua/config/plugins/lualine.lua b/roles/nvim/files/lua/config/plugins/lualine.lua similarity index 100% rename from nvim/lua/config/plugins/lualine.lua rename to roles/nvim/files/lua/config/plugins/lualine.lua diff --git a/nvim/lua/config/plugins/nvim-tree.lua b/roles/nvim/files/lua/config/plugins/nvim-tree.lua similarity index 100% rename from nvim/lua/config/plugins/nvim-tree.lua rename to roles/nvim/files/lua/config/plugins/nvim-tree.lua diff --git a/nvim/lua/config/plugins/surround.lua b/roles/nvim/files/lua/config/plugins/surround.lua similarity index 100% rename from nvim/lua/config/plugins/surround.lua rename to roles/nvim/files/lua/config/plugins/surround.lua diff --git a/nvim/lua/config/plugins/telescope.lua b/roles/nvim/files/lua/config/plugins/telescope.lua similarity index 100% rename from nvim/lua/config/plugins/telescope.lua rename to roles/nvim/files/lua/config/plugins/telescope.lua diff --git a/nvim/lua/config/plugins/todo-comments.lua b/roles/nvim/files/lua/config/plugins/todo-comments.lua similarity index 100% rename from nvim/lua/config/plugins/todo-comments.lua rename to roles/nvim/files/lua/config/plugins/todo-comments.lua diff --git a/nvim/lua/config/plugins/treesitter.lua b/roles/nvim/files/lua/config/plugins/treesitter.lua similarity index 100% rename from nvim/lua/config/plugins/treesitter.lua rename to roles/nvim/files/lua/config/plugins/treesitter.lua diff --git a/nvim/lua/config/plugins/venv-selector.lua b/roles/nvim/files/lua/config/plugins/venv-selector.lua similarity index 100% rename from nvim/lua/config/plugins/venv-selector.lua rename to roles/nvim/files/lua/config/plugins/venv-selector.lua diff --git a/nvim/lua/config/plugins/which-key.lua b/roles/nvim/files/lua/config/plugins/which-key.lua similarity index 100% rename from nvim/lua/config/plugins/which-key.lua rename to roles/nvim/files/lua/config/plugins/which-key.lua diff --git a/roles/nvim/tasks/main.yml b/roles/nvim/tasks/main.yml new file mode 100644 index 0000000..bad1f3b --- /dev/null +++ b/roles/nvim/tasks/main.yml @@ -0,0 +1,12 @@ +--- +- name: Install neovim + package: + name: neovim + state: present + +- name: Symlink neovim + file: + src: "{{ role_path }}/files" + dest: "{{ config_dir }}/nvim" + state: link + force: true diff --git a/roles/system/tasks/main.yml b/roles/system/tasks/main.yml new file mode 100644 index 0000000..67fc787 --- /dev/null +++ b/roles/system/tasks/main.yml @@ -0,0 +1,20 @@ +--- +- name: Update package cache (Arch-based systems) + pacman: + update_cache: yes + when: ansible_os_family == "Archlinux" + become: yes + +- name: Install system packages + package: + name: "{{ system_packages }}" + state: present + become: yes + +- name: Ensure .config directory exists + file: + path: "{{ config_dir }}" + state: directory + mode: '0755' + owner: "{{ ansible_user }}" + group: "{{ ansible_user }}" diff --git a/roles/zsh/files/.zshrc b/roles/zsh/files/.zshrc new file mode 100644 index 0000000..b1cc416 --- /dev/null +++ b/roles/zsh/files/.zshrc @@ -0,0 +1,52 @@ +# If you come from bash you might have to change your $PATH. +# export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH + +# Path to your Oh My Zsh installation. +export ZSH="$HOME/.oh-my-zsh" + +ZSH_THEME="bira" +zstyle ':omz:update' mode reminder # just remind me to update when it's time +COMPLETION_WAITING_DOTS="true" + +plugins=( + git + zsh-syntax-highlighting + zsh-autosuggestions + fzf-zsh-plugin +) + +source $ZSH/oh-my-zsh.sh + + +# Preferred editor for local and remote sessions +if [[ -n $SSH_CONNECTION ]]; then + export EDITOR='vim' +else + export EDITOR='nvim' +fi + +# TODO prettier solution? +DOTFILES_ZSH_DIR="${0:A:h}" + +for zsh_file in "$DOTFILES_ZSH_DIR"/*.zsh; do + [[ -r "$zsh_file" ]] && source "$zsh_file" +done + + +# TODO source all files with .zsh suffix +# source ./aliases.zsh +# source ./dev_env.zsh +# source ./tools.zsh + +# TODO +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +if [[ -n "$MACHINE_TYPE" && -f "$HOME/dotfiles/zsh/hosts/$MACHINE_TYPE.zsh" ]]; then + source "$HOME/dotfiles/zsh/hosts/$MACHINE_TYPE.zsh" +fi + + +alias drun='docker run -it --network=host --device=/dev/kfd --device=/dev/dri --group-add=video --ipc=host --cap-add=SYS_PTRACE --security-opt seccomp=unconfined' + diff --git a/zsh/aliases.zsh b/roles/zsh/files/aliases.zsh similarity index 100% rename from zsh/aliases.zsh rename to roles/zsh/files/aliases.zsh diff --git a/zsh/dev_env.zsh b/roles/zsh/files/dev_env.zsh similarity index 100% rename from zsh/dev_env.zsh rename to roles/zsh/files/dev_env.zsh diff --git a/zsh/hosts/personal.zsh b/roles/zsh/files/hosts/personal.zsh similarity index 100% rename from zsh/hosts/personal.zsh rename to roles/zsh/files/hosts/personal.zsh diff --git a/zsh/hosts/work.zsh b/roles/zsh/files/hosts/work.zsh similarity index 100% rename from zsh/hosts/work.zsh rename to roles/zsh/files/hosts/work.zsh diff --git a/zsh/tools.zsh b/roles/zsh/files/tools.zsh similarity index 100% rename from zsh/tools.zsh rename to roles/zsh/files/tools.zsh diff --git a/roles/zsh/tasks/main.yaml b/roles/zsh/tasks/main.yaml new file mode 100644 index 0000000..8cd5ac0 --- /dev/null +++ b/roles/zsh/tasks/main.yaml @@ -0,0 +1,24 @@ +--- +- name: Install zsh + package: + name: zsh + state: present + +- name: Install oh-my-zsh + shell: | + sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" --unattended + args: + creates: "{{ ansible_env.HOME }}/.oh-my-zsh" + +- name: Check for custom zshrc + stat: + path: "{{ role_path }}/files/.zshrc" + register: custom_zshrc + +- name: Symlink custom zshrc + file: + src: "{{ role_path }}/files/.zshrc" + dest: "{{ ansible_env.HOME }}/.zshrc" + state: link + force: yes + when: custom_zshrc.stat.exists diff --git a/zsh/.zshrc b/zsh/.zshrc deleted file mode 100644 index 667427a..0000000 --- a/zsh/.zshrc +++ /dev/null @@ -1,130 +0,0 @@ -# If you come from bash you might have to change your $PATH. -# export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH - -# Path to your Oh My Zsh installation. -export ZSH="$HOME/.oh-my-zsh" - -# Set name of the theme to load --- if set to "random", it will -# load a random theme each time Oh My Zsh is loaded, in which case, -# to know which specific one was loaded, run: echo $RANDOM_THEME -# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes -ZSH_THEME="bira" - -# Set list of themes to pick from when loading at random -# Setting this variable when ZSH_THEME=random will cause zsh to load -# a theme from this variable instead of looking in $ZSH/themes/ -# If set to an empty array, this variable will have no effect. -# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) - -# Uncomment the following line to use case-sensitive completion. -# CASE_SENSITIVE="true" - -# Uncomment the following line to use hyphen-insensitive completion. -# Case-sensitive completion must be off. _ and - will be interchangeable. -# HYPHEN_INSENSITIVE="true" - -# Uncomment one of the following lines to change the auto-update behavior -# zstyle ':omz:update' mode disabled # disable automatic updates -# zstyle ':omz:update' mode auto # update automatically without asking -zstyle ':omz:update' mode reminder # just remind me to update when it's time - -# Uncomment the following line to change how often to auto-update (in days). -# zstyle ':omz:update' frequency 13 - -# Uncomment the following line if pasting URLs and other text is messed up. -# DISABLE_MAGIC_FUNCTIONS="true" - -# Uncomment the following line to disable colors in ls. -# DISABLE_LS_COLORS="true" - -# Uncomment the following line to disable auto-setting terminal title. -# DISABLE_AUTO_TITLE="true" - -# Uncomment the following line to enable command auto-correction. -# ENABLE_CORRECTION="true" - -# Uncomment the following line to display red dots whilst waiting for completion. -# You can also set it to another string to have that shown instead of the default red dots. -# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f" -# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765) -COMPLETION_WAITING_DOTS="true" - -# Uncomment the following line if you want to disable marking untracked files -# under VCS as dirty. This makes repository status check for large repositories -# much, much faster. -# DISABLE_UNTRACKED_FILES_DIRTY="true" - -# Uncomment the following line if you want to change the command execution time -# stamp shown in the history command output. -# You can set one of the optional three formats: -# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" -# or set a custom format using the strftime function format specifications, -# see 'man strftime' for details. -# HIST_STAMPS="mm/dd/yyyy" - -# Would you like to use another custom folder than $ZSH/custom? -# ZSH_CUSTOM=/path/to/new-custom-folder - -# Which plugins would you like to load? -# Standard plugins can be found in $ZSH/plugins/ -# Custom plugins may be added to $ZSH_CUSTOM/plugins/ -# Example format: plugins=(rails git textmate ruby lighthouse) -# Add wisely, as too many plugins slow down shell startup. -plugins=( - git - zsh-syntax-highlighting - zsh-autosuggestions - fzf-zsh-plugin -) - -source $ZSH/oh-my-zsh.sh - -# User configuration - -# export MANPATH="/usr/local/man:$MANPATH" - -# You may need to manually set your language environment -# export LANG=en_US.UTF-8 - -# Preferred editor for local and remote sessions -if [[ -n $SSH_CONNECTION ]]; then - export EDITOR='vim' -else - export EDITOR='nvim' -fi - -# Compilation flags -# export ARCHFLAGS="-arch $(uname -m)" - -# Set personal aliases, overriding those provided by Oh My Zsh libs, -# plugins, and themes. Aliases can be placed here, though Oh My Zsh -# users are encouraged to define aliases within a top-level file in -# the $ZSH_CUSTOM folder, with .zsh extension. Examples: -# - $ZSH_CUSTOM/aliases.zsh -# - $ZSH_CUSTOM/macos.zsh -# For a full list of active aliases, run `alias`. -# -# Example aliases -# alias zshconfig="mate ~/.zshrc" -# alias ohmyzsh="mate ~/.oh-my-zsh" -# bindkey '^R' history-incremental-search-backward - -# TODO source all files with .zsh suffix -source ~/dotfiles/zsh/aliases.zsh -source ~/dotfiles/zsh/dev_env.zsh -source ~/dotfiles/zsh/tools.zsh - - - - -export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm -[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion - -if [[ -n "$MACHINE_TYPE" && -f "$HOME/dotfiles/zsh/hosts/$MACHINE_TYPE.zsh" ]]; then - source "$HOME/dotfiles/zsh/hosts/$MACHINE_TYPE.zsh" -fi - - -alias drun='docker run -it --network=host --device=/dev/kfd --device=/dev/dri --group-add=video --ipc=host --cap-add=SYS_PTRACE --security-opt seccomp=unconfined' -