diff --git a/.gitignore b/.gitignore index e69de29..9f11b75 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/README.md b/README.md index cb91c5d..e5923c5 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,13 @@ ## Installation -Run the `install.sh` script to install neovim, zsh (via oh-my-zsh) and all of the omz plugins. +```bash +pacman -S ansible-tools +ansible-galaxy install -r requirements.yml +ansible-playbook playbook.yml --ask-become-pass +``` -## nvim - --- TODO -- - -- Install nerdfont +- Install nerdfont -- TODO ## zsh diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..bf7b4a3 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,4 @@ +[default] +inventory = inventory +stdout_callback = yaml +host_key_checking = False diff --git a/group_vars/all.yml b/group_vars/all.yml new file mode 100644 index 0000000..1d46a73 --- /dev/null +++ b/group_vars/all.yml @@ -0,0 +1,102 @@ +default_roles: + # === Core System Tools (Recommended) === + - system # Essential system configurations and tools + - 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 + + # === Shell Environment === + - zsh # Modern shell with oh-my-zsh + + # === 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 + # === DevOps & Cloud Tools === + - 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 === + # - 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 + + # === 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 diff --git a/install.sh b/install.sh index 643332d..f48f7e2 100755 --- a/install.sh +++ b/install.sh @@ -1,48 +1,38 @@ #!/bin/bash -command_exists() { - command -v "$1" >/dev/null 2>&1 +set -e + +DOTFILES_DIR="$HOME/dotfiles" + + +function arch_setup() { + if ! [ -x "$(which ansible)" ]; then + echo "Installing ansible" + sudo pacman -S ansible + fi } -create_symlink() { - local source=$1 - local target=$2 - - if [ ! -e "$target" ]; then - ln -s "$source" "$target" - echo "Added symlink $source -> $target" - fi + +function detect_os() { + source /etc/os-release + echo "$ID" } -install_package() { - local package=$1 - if ! command_exists "$package"; then - # sudo dnf update && sudo dnf install "$package" - sudo pacman -S "$package" - fi -} +local_os=$(detect_os) -install_package "neovim" -create_symlink "$HOME/dotfiles/nvim" "$HOME/.config/nvim" +case $local_os in + cachyos|arch) + arch_setup + ;; + debian) + debian_setup + ;; + fedora) + fedora_setup + ;; + *) + echo "OS $local_os not supported" + exit 1 +esac -install_package "zsh" -create_symlink "$HOME/dotfiles/zsh/.zshrc" "$HOME/.zshrc" - -if [ ! -d "$HOME/.oh-my-zsh" ]; then - sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" -fi - -ZSH_CUSTOM=${ZSH_CUSTOM:-~/.oh-my-zsh/custom} - -# Install zsh-syntax-highlighting -if [ ! -d "${ZSH_CUSTOM}/plugins/zsh-syntax-highlighting" ]; then - git clone --depth 1 https://github.com/zsh-users/zsh-syntax-highlighting.git \ - ${ZSH_CUSTOM}/plugins/zsh-syntax-highlighting -fi - - -# Install zsh-syntax-highlighting -if [ ! -d "${ZSH_CUSTOM}/plugins/fzf-zsh-plugin" ]; then - git clone --depth 1 https://github.com/unixorn/fzf-zsh-plugin.git \ - ${ZSH_CUSTOM}/plugins/fzf-zsh-plugin -fi +ansible-playbook "$DOTFILES_DIR/playbook.yml" "$@" \ No newline at end of file diff --git a/inventory b/inventory new file mode 100644 index 0000000..13cfabe --- /dev/null +++ b/inventory @@ -0,0 +1,2 @@ +[local] +localhost ansible_connection=local diff --git a/playbook.yml b/playbook.yml new file mode 100644 index 0000000..a5c3ad3 --- /dev/null +++ b/playbook.yml @@ -0,0 +1,127 @@ +--- +- name: Setup dotfiles configuration + hosts: localhost + connection: local + become: false + vars: + dotfiles_dir: "{{ ansible_env.HOME }}/dotfiles" + + tasks: + - name: Install packages with pacman + become: true + pacman: + name: + - neovim + - zsh + - git + - openssh + state: present + + - 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' + 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 + diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..a937e53 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,4 @@ +--- +collections: + - community.general + - kewlfft.aur diff --git a/todo_ansible.md b/todo_ansible.md new file mode 100644 index 0000000..ec1e301 --- /dev/null +++ b/todo_ansible.md @@ -0,0 +1,238 @@ +Here's how such a role-based Ansible dotfiles configuration would work: + +## Directory Structure +``` +dotfiles/ +├── playbook.yml # Main playbook +├── group_vars/ +│ └── all.yml # Your config with default_roles +├── roles/ +│ ├── system/ +│ │ ├── tasks/main.yml +│ │ ├── vars/main.yml +│ │ └── files/ +│ ├── git/ +│ │ ├── tasks/main.yml +│ │ ├── templates/ +│ │ │ └── .gitconfig.j2 +│ │ └── vars/main.yml +│ ├── neovim/ +│ │ ├── tasks/main.yml +│ │ └── files/ +│ └── zsh/ +│ ├── tasks/main.yml +│ ├── files/ +│ │ └── .zshrc +│ └── vars/main.yml +└── inventory +``` + +## Main Configuration (`group_vars/all.yml`) +```yaml +# Your system configuration +default_roles: + - system + - git + - neovim + - zsh + - docker + +# Global variables +dotfiles_dir: "{{ ansible_env.HOME }}/dotfiles" +config_dir: "{{ ansible_env.HOME }}/.config" + +# Git configuration +git_user_name: "Johannes" +git_user_email: "johannes@example.com" +git_editor: "nvim" + +# System packages to install +system_packages: + - curl + - wget + - unzip + - tree +``` + +## Main Playbook (`playbook.yml`) +```yaml +--- +- name: Setup development environment + hosts: localhost + connection: local + become: yes + become_method: sudo + + pre_tasks: + - name: Create btrfs snapshot before changes + shell: | + sudo btrfs subvolume snapshot / /.snapshots/before-dotfiles-$(date +%Y%m%d-%H%M%S) + ignore_errors: yes + tags: [snapshot] + + roles: "{{ default_roles }}" + + post_tasks: + - name: Summary of installed roles + debug: + msg: "Completed setup for: {{ default_roles | join(', ') }}" +``` + +## Example Roles + +### System Role (`roles/system/tasks/main.yml`) +```yaml +--- +- name: Install system packages + package: + name: "{{ system_packages }}" + state: present + +- name: Ensure .config directory exists + file: + path: "{{ config_dir }}" + state: directory + mode: '0755' + +- name: Set up shell as default + user: + name: "{{ ansible_env.USER }}" + shell: /usr/bin/zsh + when: "'zsh' in default_roles" +``` + +### Git Role (`roles/git/tasks/main.yml`) +```yaml +--- +- name: Install git + package: + name: git + state: present + +- name: Check if custom gitconfig exists + stat: + path: "{{ dotfiles_dir }}/git/.gitconfig" + register: custom_gitconfig + +- name: Use custom gitconfig if available + file: + src: "{{ dotfiles_dir }}/git/.gitconfig" + dest: "{{ ansible_env.HOME }}/.gitconfig" + state: link + force: yes + when: custom_gitconfig.stat.exists + +- name: Generate gitconfig from template if no custom config + template: + src: .gitconfig.j2 + dest: "{{ ansible_env.HOME }}/.gitconfig" + mode: '0644' + when: not custom_gitconfig.stat.exists +``` + +### Git Template (`roles/git/templates/.gitconfig.j2`) +```ini +[user] + name = {{ git_user_name }} + email = {{ git_user_email }} + +[core] + editor = {{ git_editor }} + autocrlf = input + +[init] + defaultBranch = main + +[push] + default = simple +``` + +### Neovim Role (`roles/neovim/tasks/main.yml`) +```yaml +--- +- name: Install neovim + package: + name: neovim + state: present + +- name: Check for custom neovim config + stat: + path: "{{ dotfiles_dir }}/nvim" + register: nvim_config + +- name: Symlink neovim config + file: + src: "{{ dotfiles_dir }}/nvim" + dest: "{{ config_dir }}/nvim" + state: link + force: yes + when: nvim_config.stat.exists + +- name: Create basic neovim config if none exists + copy: + content: | + -- Basic Neovim configuration + vim.opt.number = true + vim.opt.expandtab = true + vim.opt.tabstop = 2 + vim.opt.shiftwidth = 2 + dest: "{{ config_dir }}/nvim/init.lua" + mode: '0644' + when: not nvim_config.stat.exists +``` + +### ZSH Role (`roles/zsh/tasks/main.yml`) +```yaml +--- +- 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: "{{ dotfiles_dir }}/zsh/.zshrc" + register: custom_zshrc + +- name: Symlink custom zshrc + file: + src: "{{ dotfiles_dir }}/zsh/.zshrc" + dest: "{{ ansible_env.HOME }}/.zshrc" + state: link + force: yes + when: custom_zshrc.stat.exists +``` + +## Usage + +**To install everything:** +```bash +ansible-playbook -i inventory playbook.yml --ask-become-pass +``` + +**To install only specific roles:** +```bash +ansible-playbook -i inventory playbook.yml --ask-become-pass --tags "git,neovim" +``` + +**To override roles temporarily:** +```bash +ansible-playbook -i inventory playbook.yml --ask-become-pass -e "default_roles=['system','git']" +``` + +## Benefits of This Approach + +1. **Modular**: Each tool is a separate role +2. **Configurable**: Easy to enable/disable tools in `all.yml` +3. **Reusable**: Roles can be shared across different machines +4. **Flexible**: Can override variables per host/group +5. **Fallback configs**: Generates basic configs when custom ones don't exist +6. **Scalable**: Easy to add new tools without touching existing code + +This approach lets you manage your entire development environment as code while keeping it organized and maintainable! diff --git a/zsh/.zshrc b/zsh/.zshrc index a620ac0..667427a 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -124,3 +124,7 @@ export NVM_DIR="$HOME/.nvm" 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' +