From ef95b6f198763ef537c996539eeb6a3d5b2894e4 Mon Sep 17 00:00:00 2001 From: Xavier Logerais Date: Wed, 15 Jul 2026 15:40:17 +0200 Subject: [PATCH] feat(mise): Automate ~/.config/mise/config.toml generation based on yaml data and some logic --- .chezmoidata/hosts.yaml | 38 ++++++++ .chezmoidata/packages.yaml | 23 +++++ .chezmoidata/tools.yaml | 62 +++++++++++++ .chezmoitemplates/mise-bootstrap-packages | 33 +++++++ .chezmoitemplates/mise-tools | 36 ++++++++ private_dot_config/mise/config.toml.tmpl | 102 ++-------------------- 6 files changed, 197 insertions(+), 97 deletions(-) create mode 100644 .chezmoidata/hosts.yaml create mode 100644 .chezmoidata/packages.yaml create mode 100644 .chezmoidata/tools.yaml create mode 100644 .chezmoitemplates/mise-bootstrap-packages create mode 100644 .chezmoitemplates/mise-tools diff --git a/.chezmoidata/hosts.yaml b/.chezmoidata/hosts.yaml new file mode 100644 index 0000000..4bc12eb --- /dev/null +++ b/.chezmoidata/hosts.yaml @@ -0,0 +1,38 @@ +--- +hosts: + # PC perso + intel-nuc-hades-canyon: + toolboxes: + - terminal + - dev-tools + - dev-languages + - ai + tools: + - vivid + - pipx:vit + - pipx:speedtest-cli + - pipx:asciinema + configs: {} + # Serveur dédié + cloud: + toolboxes: + - terminal + - dev-tools + - dev-languages + - ai + tools: + - pipx:vit + configs: {} + # Container de dev + devenv: + toolboxes: + - terminal + - dev-tools + - dev-languages + - devops + - ai + tools: + - sops + - age + - cargo:rage + configs: {} diff --git a/.chezmoidata/packages.yaml b/.chezmoidata/packages.yaml new file mode 100644 index 0000000..80bef0a --- /dev/null +++ b/.chezmoidata/packages.yaml @@ -0,0 +1,23 @@ +--- +packages: + ubuntu: + common: + - tar + - zip + - unzip + - manpages + - manpages-fr + - bash + - bash-completion + - screen + - tmux + - curl + - wget + - vim + - git + - tree + - build-essential + server: [] + desktop: + - zsh + - fish diff --git a/.chezmoidata/tools.yaml b/.chezmoidata/tools.yaml new file mode 100644 index 0000000..f67c8a7 --- /dev/null +++ b/.chezmoidata/tools.yaml @@ -0,0 +1,62 @@ +--- +tools: + toolboxes: + terminal: + - powerline-go + - lsd + - bat + - ripgrep + - fd + - gdu + - bottom + - dust + - fzf + - zoxide + - broot + - glow + dev-tools: + - lazygit + - delta + - gh + - tea + # tea = { version = "0.14.2", url = 'https://gitea.com/gitea/tea/releases/download/v{{- "{{" }} version {{ "}}" -}}/tea-{{- "{{" }} version {{ "}}" -}}-{{- "{{" }} os() {{ "}}" -}}-{{- "{{" }} arch(x64="amd64") {{ "}}" -}}.xz' } + - jq + - yq + - shellcheck + dev-languages: + - python + - uv + - pipx + - node + - go + - rust + - cargo-binstall + devops: + - docker-cli + - kubectl + - krew + - k9s + - helm + - flux2 + - kind + - crane + - dive + - trivy + - podman + - minikube + - kwok + - cosign + - lazydocker + ai: + - claude + - gemini-cli + - codex + +# # Password managers +# # vault = "latest" +# sops = "latest" +# age = "latest" +# # "cargo:rage" = "latest" +# +# # Desktop tools +# #obsidian = { version = "latest", asset_pattern = "Obsidian-{version}.AppImage" } diff --git a/.chezmoitemplates/mise-bootstrap-packages b/.chezmoitemplates/mise-bootstrap-packages new file mode 100644 index 0000000..996ead2 --- /dev/null +++ b/.chezmoitemplates/mise-bootstrap-packages @@ -0,0 +1,33 @@ +{{/* .chezmoitemplates/mise-bootstrap-packages */}} +{{- $isUbuntu := false -}} +{{- $isUbuntuServer := false -}} +{{- $isUbuntuDesktop := false -}} +{{- if and (eq .chezmoi.os "linux") (hasKey .chezmoi "osRelease") (eq .chezmoi.osRelease.id "ubuntu") -}} + {{- $isUbuntu = true -}} + {{- if stat "/usr/bin/gnome-shell" }} + {{- $isUbuntuDesktop = true -}} + {{- end }} +{{- end -}} + +{{- if $isUbuntu }} + +# Ubuntu common +{{- range .packages.ubuntu.common }} +"apt:{{- . }}" = "latest" +{{- end }} + +{{- if $isUbuntuServer }} +# Ubuntu server +{{- range .packages.ubuntu.server }} +"apt:{{- . }}" = "latest" +{{- end }} +{{- end }} + +{{- if $isUbuntuDesktop }} +# Ubuntu desktop +{{- range .packages.ubuntu.desktop }} +"apt:{{- . }}" = "latest" +{{- end }} +{{- end }} + +{{- end }} diff --git a/.chezmoitemplates/mise-tools b/.chezmoitemplates/mise-tools new file mode 100644 index 0000000..0661b7c --- /dev/null +++ b/.chezmoitemplates/mise-tools @@ -0,0 +1,36 @@ +{{/* .chezmoitemplates/mise-tools */}} +{{- $hostname := .chezmoi.hostname -}} +{{- $currentHost := index .hosts $hostname -}} + +{{- if $currentHost }} + {{- /* 1. Parcourir les toolboxes associées à cet hôte */}} + {{- range $toolboxName := $currentHost.toolboxes }} + {{- /* Récupérer la liste des outils pour cette toolbox dans tools.yaml */}} + {{- $toolsList := index $.tools.toolboxes $toolboxName }} + {{- if $toolsList }} + +# Toolbox: {{ $toolboxName }} + {{- range $tool := $toolsList }} + {{- /* Gestion fine du cas particulier de 'tea' mis en commentaire dans votre yaml */}} + {{- if eq $tool "tea" }} +tea = { version = "0.14.2", url = "https://gitea.com/gitea/tea/releases/download/v{{`{{ version }}`}}/tea-{{`{{ version }}`}}-{{`{{ os() }}`}}-{{`{{ arch(x64="amd64") }}`}}.xz" } + {{- else }} +{{ $tool }} = "latest" + {{- end }} + {{- end }} + {{- end }} + {{- end }} + + {{- /* 2. Parcourir les outils individuels (la liste 'tools:' du host) */}} + {{- if hasKey $currentHost "tools" }} + {{- if $currentHost.tools }} + +# Outils individuels + {{- range $tool := $currentHost.tools }} +{{ $tool }} = "latest" + {{- end }} + {{- end }} + {{- end }} +{{- else }} +# Aucun profil trouvé dans hosts.yaml pour la machine : {{ $hostname }} +{{- end }} diff --git a/private_dot_config/mise/config.toml.tmpl b/private_dot_config/mise/config.toml.tmpl index 81b0b60..01c3131 100644 --- a/private_dot_config/mise/config.toml.tmpl +++ b/private_dot_config/mise/config.toml.tmpl @@ -7,33 +7,7 @@ binstall = true ######################### [ Bootstrap ] ######################### [bootstrap.packages] - -"apt:tar" = "latest" -"apt:zip" = "latest" -"apt:unzip" = "latest" - -"apt:manpages" = "latest" -"apt:manpages-fr" = "latest" - -"apt:bash" = "latest" -"apt:bash-completion" = "latest" - -"apt:zsh" = "latest" -"apt:fish" = "latest" - -"apt:screen" = "latest" -"apt:tmux" = "latest" - -"apt:curl" = "latest" -"apt:wget" = "latest" - -"apt:vim" = "latest" -"apt:git" = "latest" -"apt:tree" = "latest" - -{{ if (and (eq .chezmoi.os "linux") (eq .chezmoi.osRelease.name "Ubuntu")) }} -"apt:build-essential" = "latest" -{{ end }} +{{ template "mise-bootstrap-packages" . }} # coreutils grep less # tig @@ -55,44 +29,12 @@ usage = "latest" # Configuration chezmoi = "latest" -# Terminal -# kitty = { version = "latest", asset_pattern = "kitty-*-x86_64.txz" } - # Editor neovim = "latest" tree-sitter = "latest" -# Languages - -# -- python -- -python = "latest" -uv = "latest" -pipx = "latest" - -# -- node -- -node = "latest" - -# -- go -- -go = "latest" - -# -- rust -- -rust = "latest" -cargo-binstall = "latest" - - -# Terminal tools -powerline-go = "latest" -lsd = "latest" -bat = "latest" -ripgrep = "latest" -fd = "latest" -gdu = "latest" -bottom = "latest" -dust = "latest" -fzf = "latest" -zoxide = "latest" -broot = "latest" -glow = "latest" +# Tools automated with chezmoi +{{ template "mise-tools" . }} # Password managers # vault = "latest" @@ -100,42 +42,8 @@ sops = "latest" age = "latest" # "cargo:rage" = "latest" -# Dev toolbox -lazygit = "latest" -delta = "latest" -gh = "latest" -tea = { version = "0.14.2", url = 'https://gitea.com/gitea/tea/releases/download/v{{- "{{" }} version {{ "}}" -}}/tea-{{- "{{" }} version {{ "}}" -}}-{{- "{{" }} os() {{ "}}" -}}-{{- "{{" }} arch(x64="amd64") {{ "}}" -}}.xz' } - -jq = "latest" -yq = "latest" - -# DevOps toolbox -# docker-cli = "latest" -# kubectl = "latest" -# krew = "latest" -# k9s = "latest" -# helm = "latest" -# flux2 = "2.3.0" -# kind = "latest" -# crane = "latest" -# dive = "latest" -# trivy = "latest" -# podman = "latest" -# minikube = "latest" -# kwok = "latest" -# cosign = "latest" -# lazydocker = "latest" - -# AI tools -# gemini-cli = "latest" -# claude = "latest" -# codex = "latest" +# Terminal +# kitty = { version = "latest", asset_pattern = "kitty-*-x86_64.txz" } # Desktop tools #obsidian = { version = "latest", asset_pattern = "Obsidian-{version}.AppImage" } - -shellcheck = "latest" -vivid = "latest" -"pipx:vit" = "latest" -"pipx:speedtest-cli" = "latest" -# "pipx:asciinema" = "latest"