diff --git a/ansible/environments/laptop/group_vars/all b/ansible/environments/laptop/group_vars/all index afdcfce..9577e3a 100644 --- a/ansible/environments/laptop/group_vars/all +++ b/ansible/environments/laptop/group_vars/all @@ -1,2 +1,3 @@ timezone: "America/New_York" install_bluetooth: true +emacs_flavor: "full" diff --git a/ansible/playbook.yaml b/ansible/playbook.yaml index 4aec288..9670453 100644 --- a/ansible/playbook.yaml +++ b/ansible/playbook.yaml @@ -91,7 +91,7 @@ - jail - bhyve - wireguard - - emacs + # - emacs - mrmanager - hosts: admin_git:public_dns diff --git a/ansible/roles/emacs/defaults/main.yaml b/ansible/roles/emacs/defaults/main.yaml new file mode 100644 index 0000000..8cf2a12 --- /dev/null +++ b/ansible/roles/emacs/defaults/main.yaml @@ -0,0 +1 @@ +emacs_flavor: "plain" # or full for systems where I do real development. diff --git a/ansible/roles/plainmacs/files/plainmacs b/ansible/roles/emacs/files/plainmacs similarity index 100% rename from ansible/roles/plainmacs/files/plainmacs rename to ansible/roles/emacs/files/plainmacs diff --git a/ansible/roles/emacs/files/plainmacs_init.el b/ansible/roles/emacs/files/plainmacs_init.el new file mode 100644 index 0000000..eb3964f --- /dev/null +++ b/ansible/roles/emacs/files/plainmacs_init.el @@ -0,0 +1,19 @@ +(progn + (setq make-backup-files nil auto-save-default nil create-lockfiles nil) + (load-theme 'tango-dark t) + (set-face-attribute 'default nil :background "black") + ;; Bright yellow highlighting for selected region + (set-face-attribute 'region nil :background "#ffff50" :foreground "black") + ;; Bright green cursor to distinguish from yellow region + (set-cursor-color "#ccff66") + ;; Hightlight the current line + (set-face-attribute 'line-number-current-line nil :foreground "white") + ;; Set default font + (set-face-attribute 'default nil :height 100 :width 'regular :weight 'regular :family "Cascadia Mono") + ;; Set fallback font for unicode glyphs + (set-fontset-font "fontset-default" nil (font-spec :name "Noto Color Emoji")) + (menu-bar-mode -1) + (when (fboundp 'tool-bar-mode) + (tool-bar-mode -1)) + (when ( fboundp 'scroll-bar-mode) + (scroll-bar-mode -1))) diff --git a/ansible/roles/plainmacs/files/zshrc_plainmacs b/ansible/roles/emacs/files/zshrc_plainmacs similarity index 100% rename from ansible/roles/plainmacs/files/zshrc_plainmacs rename to ansible/roles/emacs/files/zshrc_plainmacs diff --git a/ansible/roles/emacs/meta/main.yaml b/ansible/roles/emacs/meta/main.yaml index be46a20..d4281a0 100644 --- a/ansible/roles/emacs/meta/main.yaml +++ b/ansible/roles/emacs/meta/main.yaml @@ -1,5 +1,5 @@ dependencies: - users - fonts - - rust - - plainmacs + - role: rust + when: 'emacs_flavor == "full"' diff --git a/ansible/roles/emacs/tasks/common.yaml b/ansible/roles/emacs/tasks/common.yaml index 0c76f0c..b9f3c1b 100644 --- a/ansible/roles/emacs/tasks/common.yaml +++ b/ansible/roles/emacs/tasks/common.yaml @@ -1,9 +1,21 @@ - name: Install packages + when: 'emacs_flavor == "full"' package: name: - aspell state: present +- name: Install scripts + copy: + src: "files/{{ item.src }}" + dest: "{{ item.dest }}" + mode: 0755 + owner: root + group: wheel + loop: + - src: plainmacs + dest: /usr/local/bin/plainmacs + - import_tasks: tasks/freebsd.yaml when: 'os_flavor == "freebsd"' diff --git a/ansible/roles/emacs/tasks/freebsd.yaml b/ansible/roles/emacs/tasks/freebsd.yaml index cc9ab8c..9bef000 100644 --- a/ansible/roles/emacs/tasks/freebsd.yaml +++ b/ansible/roles/emacs/tasks/freebsd.yaml @@ -2,6 +2,12 @@ package: name: - emacs + state: present + +- name: Install packages + when: 'emacs_flavor == "full"' + package: + name: - py39-pygments - inkscape # to support SVGs in LaTeX # - prettier # typescript formatting diff --git a/ansible/roles/emacs/tasks/linux.yaml b/ansible/roles/emacs/tasks/linux.yaml index 68687dd..f3d0baa 100644 --- a/ansible/roles/emacs/tasks/linux.yaml +++ b/ansible/roles/emacs/tasks/linux.yaml @@ -1,7 +1,30 @@ +- name: Build aur packages + register: buildaur + become_user: "{{ build_user.name }}" + command: "aurutils-sync --no-view {{ item }}" + args: + creates: "/var/cache/pacman/custom/{{ item }}-*.pkg.tar.*" + loop: + - emacs29-git + +- name: Update cache + when: buildaur.changed + pacman: + name: [] + state: present + update_cache: true + - name: Install packages package: name: - aspell-en + - emacs29-git + state: present + +- name: Install packages + when: 'emacs_flavor == "full"' + package: + name: - prettier # typescript+yaml formatting - pyright - gopls diff --git a/ansible/roles/emacs/tasks/peruser.yaml b/ansible/roles/emacs/tasks/peruser.yaml index af5df19..a30e2a6 100644 --- a/ansible/roles/emacs/tasks/peruser.yaml +++ b/ansible/roles/emacs/tasks/peruser.yaml @@ -12,6 +12,7 @@ - ".emacs.d/elisp" - name: Configure dotfiles + when: 'emacs_flavor == "full"' copy: src: "files/{{ item.src }}" dest: "{{ account_homedir.stdout }}/{{ item.dest }}" @@ -22,7 +23,20 @@ - src: init.el dest: .emacs.d/init.el +- name: Configure dotfiles + when: 'emacs_flavor == "plain"' + copy: + src: "files/{{ item.src }}" + dest: "{{ account_homedir.stdout }}/{{ item.dest }}" + mode: 0600 + owner: "{{ account_name.stdout }}" + group: "{{ group_name.stdout }}" + loop: + - src: plainmacs_init.el + dest: .emacs.d/init.el + - name: Configure elisp files + when: 'emacs_flavor == "full"' copy: src: "files/{{ item }}" dest: "{{ account_homedir.stdout }}/.emacs.d/elisp/{{ item }}" @@ -58,7 +72,8 @@ owner: "{{ account_name.stdout }}" group: "{{ group_name.stdout }}" loop: - - emacs_e + - emacs_e # Create an alias 'e' which launches emacs + - plainmacs # Set the EDITOR to plainmacs - import_tasks: tasks/peruser_freebsd.yaml when: 'os_flavor == "freebsd"' diff --git a/ansible/roles/plainmacs/tasks/common.yaml b/ansible/roles/plainmacs/tasks/common.yaml deleted file mode 100644 index bdb96ee..0000000 --- a/ansible/roles/plainmacs/tasks/common.yaml +++ /dev/null @@ -1,25 +0,0 @@ -- name: Install scripts - copy: - src: "files/{{ item.src }}" - dest: "{{ item.dest }}" - mode: 0755 - owner: root - group: wheel - loop: - - src: plainmacs - dest: /usr/local/bin/plainmacs - -- import_tasks: tasks/freebsd.yaml - when: 'os_flavor == "freebsd"' - -- import_tasks: tasks/linux.yaml - when: 'os_flavor == "linux"' - -- include_tasks: - file: tasks/peruser.yaml - apply: - become: yes - become_user: "{{ initialize_user }}" - loop: "{{ users | dict2items | community.general.json_query('[?value.initialize==`true`].key') }}" - loop_control: - loop_var: initialize_user diff --git a/ansible/roles/plainmacs/tasks/freebsd.yaml b/ansible/roles/plainmacs/tasks/freebsd.yaml deleted file mode 100644 index 6a6413b..0000000 --- a/ansible/roles/plainmacs/tasks/freebsd.yaml +++ /dev/null @@ -1,5 +0,0 @@ -- name: Install packages - package: - name: - - emacs - state: present diff --git a/ansible/roles/plainmacs/tasks/linux.yaml b/ansible/roles/plainmacs/tasks/linux.yaml deleted file mode 100644 index 062ac74..0000000 --- a/ansible/roles/plainmacs/tasks/linux.yaml +++ /dev/null @@ -1,22 +0,0 @@ -- name: Build aur packages - register: buildaur - become_user: "{{ build_user.name }}" - command: "aurutils-sync --no-view {{ item }}" - args: - creates: "/var/cache/pacman/custom/{{ item }}-*.pkg.tar.*" - loop: - - emacs29-git - -- name: Update cache - when: buildaur.changed - pacman: - name: [] - state: present - update_cache: true - -- name: Install packages - package: - name: - - aspell-en - - emacs29-git - state: present diff --git a/ansible/roles/plainmacs/tasks/main.yaml b/ansible/roles/plainmacs/tasks/main.yaml deleted file mode 100644 index 5c1df6c..0000000 --- a/ansible/roles/plainmacs/tasks/main.yaml +++ /dev/null @@ -1 +0,0 @@ -- import_tasks: tasks/common.yaml diff --git a/ansible/roles/plainmacs/tasks/peruser.yaml b/ansible/roles/plainmacs/tasks/peruser.yaml deleted file mode 100644 index 9846c52..0000000 --- a/ansible/roles/plainmacs/tasks/peruser.yaml +++ /dev/null @@ -1,18 +0,0 @@ -- include_role: - name: per_user - -- name: Configure zshrc additional imports - copy: - src: "files/zshrc_{{ item }}" - dest: "{{ account_homedir.stdout }}/.config/ansible_deploy/zshrc/{{ item }}.zsh" - mode: 0600 - owner: "{{ account_name.stdout }}" - group: "{{ group_name.stdout }}" - loop: - - plainmacs - -- import_tasks: tasks/peruser_freebsd.yaml - when: 'os_flavor == "freebsd"' - -- import_tasks: tasks/peruser_linux.yaml - when: 'os_flavor == "linux"' diff --git a/ansible/roles/plainmacs/tasks/peruser_freebsd.yaml b/ansible/roles/plainmacs/tasks/peruser_freebsd.yaml deleted file mode 100644 index e69de29..0000000 diff --git a/ansible/roles/plainmacs/tasks/peruser_linux.yaml b/ansible/roles/plainmacs/tasks/peruser_linux.yaml deleted file mode 100644 index e69de29..0000000