-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.yml
562 lines (518 loc) · 18.3 KB
/
setup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
---
- name: Set up dev environment
hosts: localhost
vars:
dotfiles_dir: "{{ lookup('env','HOME') }}/.dotfiles"
alacritty_binary_path: "/usr/local/bin/alacritty"
alacritty_version: "0.13.0" # https://github.com/alacritty/alacritty/tags
apt_packages:
cli:
# Dev tools
- fd-find
- fzf
- git
- ripgrep
- shellcheck
- tig
- tmux
- zsh
# Utils
- curl
- htop
- net-tools
- nload
- stow
- python3-psutil
- python3-venv
- ncdu
- uuid
- jq
- unzip
# System packages
- fuse
gui:
# Utils
- xdotool
- xsel
- xclip
# GUI apps
- arandr
- flameshot
- gromit-mpx
- meld
- pavucontrol
- speedcrunch
- rofi
pre_tasks:
- name: Set WSL fact
set_fact:
in_wsl: "{{ lookup('env', 'WSL_DISTRO_NAME') != '' }}"
tags: wsl
- name: Check if GTK is installed
ansible.builtin.shell: "bash -c 'dpkg -l | grep gtk'"
register: gtk_check
ignore_errors: yes
check_mode: no
changed_when: false
- name: Set GTK fact
set_fact:
has_gtk: "{{ gtk_check.rc == 0 }}"
tasks:
- name: Install GUI packages
tags: apt
become: true
apt:
pkg: "{{ apt_packages.gui }}"
when: has_gtk or not wsl
- name: Install CLI packages
tags: apt
become: true
apt:
pkg: "{{ apt_packages.cli }}"
- name: Create dotfile directories
# This is created so that the stowing of certain directories only creates symlinks to the
# files and not to any directory above.
ansible.builtin.file:
path: "{{ lookup('env','HOME') }}/{{ item }}"
state: directory
recurse: yes
with_items:
- .config/alacritty
- .config/autostart
- .config/nvim
- .config/systemd/user
- bin
- name: Stow dotfiles
tags: stow
ansible.builtin.shell:
chdir: "{{ dotfiles_dir }}"
cmd: "stow --verbose {{ item }}"
register: stow_out
changed_when: 'stow_out.stderr is search("LINK: ")'
when: not in_wsl
with_items:
- alacritty
- bin
- gdb
- git
- i3
- tmux
- nvim
- xmodmap
- zsh
- name: Download and install nerd font
# https://github.com/ryanoasis/nerd-fonts/tags
tags: font
vars:
font_version: "v3.1.1"
fonts_dir: "{{ lookup('env','HOME') }}/.fonts"
block:
- name: Check if fonts are installed
ansible.builtin.stat:
path: "{{ fonts_dir }}/JetBrains Mono Regular Nerd Font Complete.ttf"
register: font_result
- name: Create fonts directory
ansible.builtin.file:
path: "{{ fonts_dir }}"
state: directory
when: not font_result.stat.exists
- name: Download fonts
ansible.builtin.unarchive:
src: "https://github.com/ryanoasis/nerd-fonts/releases/download/{{ font_version }}/JetBrainsMono.zip"
dest: "{{ fonts_dir }}"
remote_src: yes
when: not font_result.stat.exists
- name: Install nvm and Nodejs
# https://github.com/nvm-sh/nvm/tags
tags: node
vars:
nvm_version: "v0.39.2"
block:
- name: Install nvm
ansible.builtin.shell: "curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/{{ nvm_version }}/install.sh | bash"
args:
creates: "{{ lookup('env','HOME') }}/.nvm/nvm.sh"
- name: Install Node.js
ansible.builtin.shell: '. {{ ansible_env.HOME }}/.nvm/nvm.sh; nvm install --lts'
args:
creates: "{{ ansible_env.HOME }}/.nvm/versions/node"
chdir: "{{ ansible_env.HOME }}"
executable: /bin/zsh
- name: Install Rustup and Cargo
tags: rust
block:
- name: Rustup
ansible.builtin.shell: "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --no-modify-path -y"
register: curl_out
changed_when: 'not (curl_out.stdout | regex_search("unchanged|skipped"))'
args:
executable: /bin/zsh
- name: Use the stable Rust compiler
ansible.builtin.shell: "rustup override set stable"
changed_when: false
args:
executable: /bin/zsh
- name: Make sure that the Rust compiler is up to date
ansible.builtin.shell: "rustup update stable"
changed_when: false
args:
executable: /bin/zsh
# Install with `nix-env -iA nixpkgs.go`
#
# - name: Install Golang
# tags: go
# vars:
# go_version: "1.20.4"
# go_checksum: "698ef3243972a51ddb4028e4a1ac63dc6d60821bf18e59a807e051fee0a385bd"
# become: yes
# block:
# - name: Download tarball
# become: yes
# ansible.builtin.get_url:
# url: "https://go.dev/dl/go{{ go_version }}.linux-amd64.tar.gz"
# dest: /tmp/go.tar.gz
# mode: "0644"
# checksum: "sha256:{{ go_checksum }}"
#
# - name: Uncompress tarball
# ansible.builtin.unarchive:
# src: /tmp/go.tar.gz
# dest: /tmp/
# remote_src: yes
#
# - name: Copy binaries
# copy:
# src: "/tmp/go/bin/{{ item }}"
# dest: "/usr/local/bin/{{ item }}"
# mode: "0755"
# remote_src: yes
# with_items:
# - go
# - gofmt
#
# - name: Cleanup tarball
# ansible.builtin.file:
# path: /tmp/go.tar.gz
# state: absent
# Install with `nix-env -iA nixpkgs.lf`
#
# - name: Install lf
# # https://github.com/gokcehan/lf/tags
# tags: lf
# vars:
# lf_version: "r31"
# lf_install_dir: "{{ lookup('env','HOME') }}/.local/bin/"
# block:
# - name: Register current lf version
# ansible.builtin.shell: "{{ lf_install_dir }}/lf --version"
# register: lf_version_call
# ignore_errors: yes
# changed_when: false
#
# - name: Decide if installation of lf should continue
# set_fact:
# install_lf: "{{ lf_version_call is defined and lf_version_call.stdout != lf_version }}"
#
# - name: Create temporary build directory
# ansible.builtin.tempfile:
# state: directory
# suffix: build
# register: lf_tmp
# when: install_lf
#
# - name: Download lf
# ansible.builtin.get_url:
# url: "https://github.com/gokcehan/lf/releases/download/{{ lf_version }}/lf-linux-amd64.tar.gz"
# dest: "{{ lf_tmp.path }}/lf.tar.gz"
# when: install_lf
#
# - name: Unpack lf
# ansible.builtin.unarchive:
# src: "{{ lf_tmp.path }}/lf.tar.gz"
# dest: "{{ lf_install_dir }}"
# when: install_lf
#
# - name: Cleanup tarball
# ansible.builtin.file:
# path: "{{ lf_tmp.path }}"
# state: absent
# when: install_lf
- name: Install oh-my-zsh
tags: zsh
vars:
oh_my_zsh_dir: "{{ lookup('env','HOME') }}/.oh-my-zsh"
block:
- name: Register oh-my-zsh directory
ansible.builtin.stat:
path: "{{ oh_my_zsh_dir }}"
register: oh_my_zsh_dir_stat
changed_when: false
- name: Decide if installation of oh-my-zsh should continue
set_fact:
install_oh_my_zsh: "{{ oh_my_zsh_dir_stat is defined and not oh_my_zsh_dir_stat.stat.exists }}"
- name: Create temporary build directory
ansible.builtin.tempfile:
state: directory
suffix: build
register: oh_my_zsh_tmp
when: install_oh_my_zsh
- name: Download oh_my_zsh
ansible.builtin.get_url:
url: "https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh"
dest: "{{ oh_my_zsh_tmp.path }}/install.sh"
when: install_oh_my_zsh
- name: Install oh_my_zsh
ansible.builtin.shell: "/bin/sh {{ oh_my_zsh_tmp.path }}/install.sh --unattended --keep-zshrc"
when: install_oh_my_zsh
- name: Cleanup install.sh
ansible.builtin.file:
path: "{{ oh_my_zsh_tmp.path }}"
state: absent
when: install_oh_my_zsh
- name: Install auto suggestions
ansible.builtin.git:
repo: https://github.com/zsh-users/zsh-autosuggestions.git
dest: "{{ oh_my_zsh_dir }}/plugins/zsh-autosuggestions"
depth: 1
- name: Install syntax highlighting
ansible.builtin.git:
repo: https://github.com/zsh-users/zsh-syntax-highlighting.git
dest: "{{ oh_my_zsh_dir }}/plugins/zsh-syntax-highlighting"
depth: 1
- name: Set zsh as default shell
become: yes
ansible.builtin.user:
name: "{{ ansible_user_id }}"
shell: /bin/zsh
# Install with `nix-env -iA nixpkgs.delta`
#
# - name: Install delta
# # https://github.com/dandavison/delta/tags
# tags: delta
# vars:
# delta_version: "0.16.5"
# delta_expected_version_output: "\u001b[0mdelta {{ delta_version }}\n\u001b[0m" # Stupid escape codes...
# block:
# - name: Register current delta version
# ansible.builtin.shell: "delta --version"
# register: delta_version_call
# ignore_errors: yes
# changed_when: false
#
# - name: Install delta's deb package
# become: yes
# apt:
# deb: "https://github.com/dandavison/delta/releases/download/{{ delta_version }}/git-delta_{{ delta_version }}_amd64.deb"
# when: delta_version_call is defined and delta_version_call.stdout != delta_expected_version_output
# Install with `nix-env -iA nixpkgs.neovim`
#
# - name: Install Neovim
# # https://github.com/neovim/neovim/tags
# tags: nvim
# vars:
# nvim_version: "0.9.0"
# nvim_expected_version_output: "NVIM v{{ nvim_version }}"
# block:
# - name: Register current nvim version
# ansible.builtin.shell: "nvim --version | grep -P -o 'NVIM v\\d+\\.\\d+\\.\\d+'"
# register: nvim_version_call
# ignore_errors: yes
# changed_when: false
#
# - name: Download and install nvim's appimage
# become: yes
# ansible.builtin.get_url:
# url: "https://github.com/neovim/neovim/releases/download/v{{ nvim_version }}/nvim.appimage"
# dest: /usr/local/bin/nvim
# mode: "0755"
# checksum: "sha256:https://github.com/neovim/neovim/releases/download/v{{ nvim_version }}/nvim.appimage.sha256sum"
# when: nvim_version_call is defined and nvim_version_call.stdout != nvim_expected_version_output
#
# - name: Install Packer.nvim
# ansible.builtin.git:
# repo: https://github.com/wbthomason/packer.nvim
# dest: "{{ lookup('env','HOME') }}/.local/share/nvim/site/pack/packer/start/packer.nvim"
# depth: 1
#
# - name: Install nvim plugins
# ansible.builtin.shell: "nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'"
# changed_when: false
- name: Enable weather systemd units
tags: weather
when: not in_wsl
block:
- name: Enable weather service
ansible.builtin.systemd:
daemon_reload: yes
scope: user
name: weather.service
enabled: yes
- name: Enable weather timer
ansible.builtin.systemd:
scope: user
name: weather.timer
state: started
enabled: yes
# - name: Set dconf settings
# tags: gnome
# dconf:
# key: "{{ item.key }}"
# value: "{{ item.value }}"
# with_items:
# - name: Set windows action key
# key: "/org/gnome/desktop/wm/preferences/mouse-button-modifier"
# value: "'<Alt>'"
# - name: Set a flat mouse acceleration profile
# key: "/org/gnome/desktop/peripherals/mouse/accel-profile"
# value: "'flat'"
# - name: Disable notifications when screen is locked
# key: "/org/gnome/desktop/notifications/show-in-lock-screen"
# value: "false"
# - name: Don't attach modal windows to its parent
# key: "/org/gnome/mutter/attach-modal-dialogs"
# value: "true"
# - name: Show week numbers
# key: "/org/gnome/desktop/calendar/show-weekdate"
# value: "true"
# - name: Set blank screen timeout (seconds)
# key: "/org/gnome/desktop/session/idle-delay"
# value: "uint32 {{ 10 * 60 }}"
# - name: Disable default terminal shortcut
# key: "/org/gnome/settings-daemon/plugins/media-keys/terminal"
# value: "@as []"
# when: has_gtk
#
# - name: Set keyboard shortcuts
# tags: shortcuts
# vars:
# keyboard_shortcuts:
# - index: 0
# name: "'Launch Alacritty'"
# command: "'alacritty'"
# binding: "'<Primary><Alt>t'"
# - index: 1
# name: "'Flameshot'"
# command: "'flameshot gui'"
# binding: "'Print'"
# - index: 2
# name: "'Set dual display'"
# command: "'{{ lookup('env', 'HOME') }}/.screenlayout/default.sh'"
# binding: "'<Primary><Alt>1'"
# - index: 3
# name: "'Set main display only'"
# command: "'{{ lookup('env', 'HOME') }}/.screenlayout/main-only.sh'"
# binding: "'<Primary><Alt>0'"
# - index: 4
# name: "'Activate snippets'"
# command: "'{{ lookup('env', 'HOME') }}/bin/snippets.sh'"
# binding: "'<Primary><Alt>s'"
# when: has_gtk
# block:
# - name: Set shortcut names
# dconf:
# key: "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom{{ item.index }}/name"
# value: "{{ item.name }}"
# with_items: "{{ keyboard_shortcuts }}"
#
# - name: Set shortcut commands
# dconf:
# key: "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom{{ item.index }}/command"
# value: "{{ item.command }}"
# with_items: "{{ keyboard_shortcuts }}"
#
# - name: Set shortcut binding
# dconf:
# key: "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom{{ item.index }}/binding"
# value: "{{ item.binding }}"
# with_items: "{{ keyboard_shortcuts }}"
#
# - name: Generate shortcut list
# set_fact:
# shortcut_list: "{{ [prefix] | product(indices) | map('join') | list | product([suffix]) | map('join') | list }}"
# vars:
# prefix: "'/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom"
# suffix: "/'"
# indices: "{{ keyboard_shortcuts | map(attribute='index') }}"
#
# - name: Set shortcut list
# dconf:
# key: "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings"
# value: "[{{ ','.join(shortcut_list) }}]"
- name: Register current Alacritty version
ansible.builtin.shell: "{{ alacritty_binary_path }} --version | grep -P -o '\\d+\\.\\d+\\.\\d+'"
register: alacritty_version_call
ignore_errors: yes
changed_when: false
tags: alacritty
- name: Decide if Alacritty build should continue
set_fact:
build_alacritty: "{{ has_gtk and alacritty_version_call is defined and alacritty_version_call.stdout != alacritty_version }}"
tags: alacritty
- name: Build Alacritty
when: build_alacritty
vars:
git_dir: "{{ lookup('env','HOME') }}/Dev/other"
repo_dir: "{{ git_dir }}/alacritty"
tags: alacritty
block:
# Installation instructions: https://github.com/alacritty/alacritty/blob/master/INSTALL.md
- name: Install build dependencies
become: true
ansible.builtin.apt:
pkg:
- cmake
- libfontconfig1-dev
- libfreetype6-dev
- libxcb-xfixes0-dev
- libxkbcommon-dev
- pkg-config
- python3
- name: Set up repo directory
ansible.builtin.file:
path: "{{ git_dir }}"
state: directory
recurse: yes
- name: Clone repo
diff: no
ansible.builtin.git:
repo: [email protected]:alacritty/alacritty.git
dest: "{{ repo_dir }}"
version: "v{{ alacritty_version }}"
depth: 1
- name: Build Alacritty
ansible.builtin.shell: "cargo build --release"
register: build_out
changed_when: 'build_out.stderr is search("Compiling alacritty")'
args:
chdir: "{{ repo_dir }}"
executable: /bin/zsh
- name: Install files
become: true
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
with_items:
- src: "{{ repo_dir }}/target/release/alacritty"
dest: "{{ alacritty_binary_path }}"
mode: "0755"
- src: "{{ repo_dir }}/extra/logo/alacritty-term.svg"
dest: "/usr/share/pixmaps/Alacritty.svg"
mode: "0644"
- name: Install .desktop file
become: true
ansible.builtin.shell: "desktop-file-install extra/linux/Alacritty.desktop"
args:
creates: "/usr/share/applications/Alacritty.desktop"
chdir: "{{ repo_dir }}"
- name: Update desktop database
become: true
ansible.builtin.shell: "update-desktop-database"
# ---
# TODO:
# - Install Syncthing https://gist.github.com/carlwgeorge/dbe186ce7562843932ebd03ccccd1a6d
# - Install pip packages
# - virtualenvwrapper
#
# References:
# - https://gist.github.com/carlwgeorge/c560a532b6929f49d9c0df52f75a68ae