From 5a67bcffd091058bf6415487fca44819027867eb Mon Sep 17 00:00:00 2001 From: Vincent Capelle Date: Sun, 17 Nov 2024 19:38:31 -0500 Subject: [PATCH] feat: add Ubuntu support --- Dockerfile | 4 ++-- ansible/playbook.yml | 27 +++++++++++++++++++++++++-- manjaro_packages => arch_packages | 0 setup.sh | 28 +++++++++++++++++++++------- ubuntu_packages | 10 ++++++++++ zsh/zshrc | 6 +++++- 6 files changed, 63 insertions(+), 12 deletions(-) rename manjaro_packages => arch_packages (100%) create mode 100644 ubuntu_packages diff --git a/Dockerfile b/Dockerfile index aee2fba..3dadda0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,10 +33,10 @@ EOF # Install the packages Ansible will want to install later. There's no need to # excessively download packages from the Manjaro repo every build... -COPY manjaro_packages . +COPY arch_packages . RUN <<-EOF sudo pacman -Syu --noconfirm - sudo pacman -S --needed --noconfirm - < manjaro_packages + sudo pacman -S --needed --noconfirm - < arch_packages EOF FROM install AS copy diff --git a/ansible/playbook.yml b/ansible/playbook.yml index bea1313..4799500 100644 --- a/ansible/playbook.yml +++ b/ansible/playbook.yml @@ -3,19 +3,42 @@ connection: local vars: + arch_distro: "Archlinux" + ubuntu_distro: "Ubuntu" + supported_distros: [ "{{ arch_distro }}", "{{ ubuntu_distro }}" ] base_dir: '{{ playbook_dir | dirname }}' gitignore_path: '{{ base_dir }}/git/gitignore' git_aliases_path: '{{ base_dir }}/aliases/git' + arch_packages: "{{ lookup('file', base_dir ~ '/arch_packages').splitlines() }}" + ubuntu_packages: "{{ lookup('file', base_dir ~ '/ubuntu_packages').splitlines() }}" tasks: - - name: Install packages + - ansible.builtin.debug: + msg: "supported_distros: {{ supported_distros }}" + - name: Stop if OS is unsupported + fail: + msg: "{{ ansible_distribution }} not supported" + when: ansible_distribution not in supported_distros + + - name: Install packages (Arch) + ansible.builtin.package: + name: "{{ packages }}" + state: present + vars: + packages: "{{ arch_packages }}" + become: true + tags: packages + when: ansible_distribution == arch_distro + + - name: Install packages (Ubuntu) ansible.builtin.package: name: "{{ packages }}" state: present vars: - packages: "{{ lookup('file', base_dir ~ '/manjaro_packages').splitlines() }}" + packages: "{{ ubuntu_packages }}" become: true tags: packages + when: ansible_distribution == ubuntu_distro - name: Change shell to zsh become: yes diff --git a/manjaro_packages b/arch_packages similarity index 100% rename from manjaro_packages rename to arch_packages diff --git a/setup.sh b/setup.sh index 27d397d..5c781b6 100755 --- a/setup.sh +++ b/setup.sh @@ -6,18 +6,32 @@ DOTFILES_DIR="$HOME/.dotfiles" ANSIBLE_PATH="$HOME/.local/bin" PLAYBOOK_PATH="$DOTFILES_DIR/ansible/playbook.yml" -sudo pacman -S --needed --noconfirm git python-pipx -pipx install --include-deps ansible +# Detect distro +if [ -f /etc/os-release ]; then + # freedesktop.org and systemd + . /etc/os-release + OS=$NAME +fi -if [ ! -d $DOTFILES_DIR ] +if [ "$OS" = "Manjaro Linux" ] || [ "$OS" = "Arch Linux" ]; then + sudo pacman -S --needed --noconfirm git python-pipx +elif [ "$OS" = "Ubuntu" ]; then + sudo apt --assume-yes install git pipx +else + echo "Distribution $OS not supported" + exit 1 +fi + +pipx install --include-deps ansible +if [ ! -d "$DOTFILES_DIR" ] then - git clone --recurse-submodules https://github.com/vicnett/dotfiles.git $DOTFILES_DIR + git clone --recurse-submodules https://github.com/vicnett/dotfiles.git "$DOTFILES_DIR" fi -if [ -f $PLAYBOOK_PATH ] +if [ -f "$PLAYBOOK_PATH" ] then - $ANSIBLE_PATH/ansible-playbook $PLAYBOOK_PATH + "$ANSIBLE_PATH/ansible-playbook" "$PLAYBOOK_PATH" else - echo Ansible playbook not found at $PLAYBOOK_PATH + echo "Ansible playbook not found at $PLAYBOOK_PATH" exit 1 fi diff --git a/ubuntu_packages b/ubuntu_packages new file mode 100644 index 0000000..211a73d --- /dev/null +++ b/ubuntu_packages @@ -0,0 +1,10 @@ +alacritty +build-essential +byobu +universal-ctags +fd-find +fzf +npm +ripgrep +unzip +zsh diff --git a/zsh/zshrc b/zsh/zshrc index 127b5f6..9bd0f2f 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -61,4 +61,8 @@ fi [[ ! -f $ZDOTDIR/.p10k.zsh ]] || source $ZDOTDIR/.p10k.zsh # Shell integrations -eval "$(fzf --zsh)" +if [ -f ~/.fzf.zsh ]; then + source ~/.fzf.zsh +else + eval "$(fzf --zsh)" +fi