Compare commits
1 Commits
main
...
f0511c8362
Author | SHA1 | Date | |
---|---|---|---|
f0511c8362 |
@@ -1,15 +0,0 @@
|
||||
{{- $email := promptStringOnce . "email" "What's your email" }}
|
||||
{{- $git_name := promptStringOnce . "git_name" "What's your Git name" }}
|
||||
|
||||
{{- $shell := promptBoolOnce . "features.shell" "Do you want to install the Fish shell" true }}
|
||||
{{- $git := promptBoolOnce . "features.git" "Do you want to install Git" true }}
|
||||
{{- $editor := promptBoolOnce . "features.editor" "Do you want to install Neovim" true }}
|
||||
|
||||
[data]
|
||||
email = {{ $email | quote }}
|
||||
git_name = {{ $git_name | quote }}
|
||||
|
||||
[data.features]
|
||||
shell = {{ $shell }}
|
||||
git = {{ $git }}
|
||||
editor = {{ $editor }}
|
2
.chezmoiignore
Normal file
2
.chezmoiignore
Normal file
@@ -0,0 +1,2 @@
|
||||
LICENSE
|
||||
README.md
|
@@ -1 +0,0 @@
|
||||
home
|
26
README.md
26
README.md
@@ -1,39 +1,19 @@
|
||||
<div align="center">
|
||||
|
||||
# ~/.dotfiles 🏡
|
||||
# ./dotfiles 🏡
|
||||
|
||||
[](https://chezmoi.io/)
|
||||
[](https://ansible.com/)
|
||||
[](https://choosealicense.com/licenses/mit/)
|
||||
|
||||
</div><br>
|
||||
|
||||
> My dotfiles, managed with [chezmoi](https://chezmoi.io/) and
|
||||
> [Ansible](https://ansible.com/)
|
||||
> My dotfiles, managed with [chezmoi](https://chezmoi.io/)
|
||||
|
||||
## Usage
|
||||
|
||||
Install [chezmoi](https://chezmoi.io/install/), then run:
|
||||
Install [chezmoi](https://chezmoi.io/), then run:
|
||||
|
||||
```sh
|
||||
# Initialize the repository
|
||||
chezmoi init git.nicolabelluti.me/nicolabelluti
|
||||
# You can also just use
|
||||
# `chezmoi init nicolabelluti`
|
||||
# if you want to use the GitHub mirror
|
||||
|
||||
# Apply the dotfiles
|
||||
chezmoi apply
|
||||
```
|
||||
|
||||
If you want to update the dotfiles:
|
||||
|
||||
```sh
|
||||
chezmoi update --init
|
||||
```
|
||||
|
||||
To give a new answer to the prompts:
|
||||
|
||||
```sh
|
||||
chezmoi init --prompt
|
||||
```
|
||||
|
@@ -1 +0,0 @@
|
||||
../.chezmoi.toml.tmpl
|
@@ -1,12 +0,0 @@
|
||||
{{- if not .features.shell }}
|
||||
.config/fish
|
||||
.config/starship.toml
|
||||
{{- end }}
|
||||
|
||||
{{- if not .features.git }}
|
||||
.config/git
|
||||
{{- end }}
|
||||
|
||||
{{- if not .features.editor }}
|
||||
.config/nvim
|
||||
{{- end }}
|
@@ -1,68 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Check is the script is being run using chezmoi
|
||||
{{- if false }}
|
||||
echo "This script must be run using chezmoi! Aborting..."
|
||||
exit 1
|
||||
{{- end }}
|
||||
|
||||
# Run this script only on Arch Linux
|
||||
{{- if ne .chezmoi.osRelease.id "arch" }}
|
||||
exit 0
|
||||
{{- end }}
|
||||
|
||||
# Make the script stop if something goes wrong:
|
||||
# -e: any command fails
|
||||
# -u: unset variable is used
|
||||
# -o pipefail: a pipeline fails if any command fails
|
||||
set -euo pipefail
|
||||
|
||||
# Show a clear error before exiting
|
||||
SCRIPT_PATH="{{ trimPrefix "/" (trimPrefix .chezmoi.workingTree (joinPath .chezmoi.sourceDir .chezmoi.sourceFile)) }}"
|
||||
trap 'echo -e "\n\033[1;31mError: Script \"$SCRIPT_PATH\" failed at line $LINENO\033[0m\n" >&2; exit 1' ERR
|
||||
|
||||
# </init>
|
||||
# <core>
|
||||
|
||||
# Ask for confirmation before running the script
|
||||
while true; do
|
||||
read -p "Do you want to run the setup script? [Y/n]: " -n 1 -r REPLY
|
||||
|
||||
# Clear the input buffer and add a newline
|
||||
while read -t 0.001 TMP; do continue; done
|
||||
echo
|
||||
|
||||
# Convert to lowercase and default to 'y' if empty
|
||||
REPLY=${REPLY:-y}
|
||||
|
||||
case $REPLY in
|
||||
Y|y|1) break ;;
|
||||
N|n|0) exit 0 ;;
|
||||
*) echo "Invalid input. Please enter y or n." ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Check if python3 and python3-venv are installed
|
||||
if ! command -v python3 >/dev/null 2>&1; then
|
||||
echo -e "\e[1;34mpython3 not found. Installing it...\e[0m"
|
||||
sudo pacman --noconfirm -Sy python
|
||||
fi
|
||||
|
||||
ANSIBLE_ROOT="{{ .chezmoi.workingTree }}/setup-script"
|
||||
|
||||
# Check if there is a venv in "setup-script/"
|
||||
if [ ! -d "$ANSIBLE_ROOT/.venv" ]; then
|
||||
echo -e "\e[1;34mNo venv found in "$ANSIBLE_ROOT". Creating one...\e[0m"
|
||||
python3 -m venv "$ANSIBLE_ROOT/.venv"
|
||||
|
||||
echo -e "\e[1;34mInstalling the dependencies...\e[0m"
|
||||
"$ANSIBLE_ROOT/.venv/bin/pip3" install -r "$ANSIBLE_ROOT/requirements.txt"
|
||||
fi
|
||||
|
||||
# Run the playbook
|
||||
echo -e "\e[1;34mRunning the playbook...\e[0m"
|
||||
ANSIBLE_CONFIG="$ANSIBLE_ROOT/ansible.cfg" \
|
||||
"$ANSIBLE_ROOT/.venv/bin/ansible-playbook" \
|
||||
"$ANSIBLE_ROOT/playbook.yaml" \
|
||||
--extra-vars "$(chezmoi data --format=json)" \
|
||||
--ask-become-pass
|
@@ -1,7 +0,0 @@
|
||||
abbr --add --position command l ls -lAh
|
||||
|
||||
{{- if .features.editor }}
|
||||
# Alias `vi` and `vim` to Neovim
|
||||
abbr --add --position command vim nvim
|
||||
abbr --add --position command vi nvim
|
||||
{{- end }}
|
@@ -1,4 +0,0 @@
|
||||
{{- if .features.editor }}
|
||||
# Set Neovim to be the default editor
|
||||
set --export EDITOR nvim
|
||||
{{- end }}
|
@@ -1,2 +0,0 @@
|
||||
# Add `~/.local/bin` to PATH
|
||||
set fish_user_paths {{ joinPath .chezmoi.homeDir ".local/bin" }}
|
@@ -1,5 +0,0 @@
|
||||
# Disable the default Fish greeting message
|
||||
set fish_greeting ""
|
||||
|
||||
# Initialize Starship
|
||||
starship init fish | source
|
@@ -1,30 +0,0 @@
|
||||
[user]
|
||||
email = {{ .email }}
|
||||
name = {{ .git_name }}
|
||||
|
||||
[init]
|
||||
defaultBranch = main
|
||||
|
||||
[merge]
|
||||
ff = true
|
||||
|
||||
{{- $credentialHelperPath := "" }}
|
||||
{{- if eq .chezmoi.osRelease.id "arch" }}
|
||||
{{- $credentialHelperPath = "/usr/lib/git-core/git-credential-libsecret" }}
|
||||
{{- end }}
|
||||
|
||||
{{- if $credentialHelperPath }}
|
||||
[credential]
|
||||
helper = {{ $credentialHelperPath }}
|
||||
{{- end }}
|
||||
|
||||
{{- $projectsDir := joinPath .chezmoi.homeDir "Projects" }}
|
||||
{{- if stat $projectsDir }}
|
||||
{{- $projects := output "find" $projectsDir "-type" "f" "-mindepth" "2" "-maxdepth" "2" "-name" ".gitconfig" | trim | splitList "\n" }}
|
||||
{{- range $projects }}
|
||||
{{- if . }}
|
||||
[includeIf "gitdir:{{ . | dir }}/**/"]
|
||||
path = {{ . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
@@ -1,6 +0,0 @@
|
||||
-- Enable relative line numbers
|
||||
vim.opt.number = true
|
||||
vim.opt.relativenumber = true
|
||||
|
||||
-- Highlight the current line
|
||||
vim.opt.cursorline = true
|
2
setup-script/.gitignore
vendored
2
setup-script/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
.ansible
|
||||
.venv
|
@@ -1,27 +0,0 @@
|
||||
[defaults]
|
||||
# (path) The default root path for Ansible config files on the controller.
|
||||
home=./.ansible
|
||||
|
||||
# (boolean) If you have cowsay installed but want to avoid the 'cows' (why????), use this.
|
||||
nocows = true
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Roles.
|
||||
roles_path = ./roles
|
||||
|
||||
# (boolean) By default, Ansible will issue a warning when there are no hosts in the inventory.
|
||||
# These warnings can be silenced by adjusting this setting to False.
|
||||
localhost_warning = false
|
||||
|
||||
# (str) Define the task result format used in the callback output.
|
||||
# These formats do not cause the callback to emit valid JSON or YAML formats.
|
||||
# The output contains these formats interspersed with other non-machine parsable data.
|
||||
callback_result_format = yaml
|
||||
|
||||
[diff]
|
||||
# (bool) Configuration toggle to tell modules to show differences when in 'changed' status, equivalent to ``--diff``.
|
||||
always = true
|
||||
|
||||
[inventory]
|
||||
# (boolean) By default, Ansible will issue a warning when no inventory was loaded and notes that it will use an implicit localhost-only inventory.
|
||||
# These warnings can be silenced by adjusting this setting to False.
|
||||
inventory_unparsed_warning = false
|
@@ -1,31 +0,0 @@
|
||||
- name: Prepare the base environment
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
|
||||
pre_tasks:
|
||||
- name: Ensure the "chezmoi" variable is set
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- chezmoi is not undefined
|
||||
- chezmoi is mapping
|
||||
fail_msg: 'Pass with: --extra-vars "$(chezmoi data --format=json)"'
|
||||
|
||||
- name: Verify the become password is correct
|
||||
become: true
|
||||
ansible.builtin.command:
|
||||
cmd: "true"
|
||||
changed_when: false
|
||||
|
||||
- name: Verify the distro
|
||||
ansible.builtin.debug:
|
||||
msg: "The setup script for now supports only Arch Linux!"
|
||||
when: chezmoi.osRelease.id != "arch"
|
||||
|
||||
roles:
|
||||
- role: shell
|
||||
when: features.shell == true
|
||||
- role: git
|
||||
when: features.git == true
|
||||
- role: editor
|
||||
when: features.editor == true
|
@@ -1 +0,0 @@
|
||||
ansible == 12.0.0
|
@@ -1,5 +0,0 @@
|
||||
- name: Install Neovim on Arch
|
||||
become: true
|
||||
ansible.builtin.pacman:
|
||||
name: neovim
|
||||
when: chezmoi.osRelease.id == "arch"
|
@@ -1,5 +0,0 @@
|
||||
- name: Install Git on Arch
|
||||
become: true
|
||||
ansible.builtin.pacman:
|
||||
name: git
|
||||
when: chezmoi.osRelease.id == "arch"
|
@@ -1,20 +0,0 @@
|
||||
- name: Install Fish shell and Starship on Arch
|
||||
become: true
|
||||
ansible.builtin.pacman:
|
||||
name:
|
||||
- fish
|
||||
- starship
|
||||
- ttf-nerd-fonts-symbols # Required for Starship
|
||||
when: chezmoi.osRelease.id == "arch"
|
||||
|
||||
- name: Find Fish shell binary
|
||||
command: which fish
|
||||
register: fish_path
|
||||
changed_when: false
|
||||
failed_when: fish_path.rc != 0
|
||||
|
||||
- name: Set the user's shell
|
||||
become: true
|
||||
ansible.builtin.user:
|
||||
name: "{{ chezmoi.username }}"
|
||||
shell: "{{ fish_path.stdout }}"
|
Reference in New Issue
Block a user