mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 19:09:44 +00:00
add meta profiles doc
This commit is contained in:
5
docs/config-profiles.md
vendored
5
docs/config-profiles.md
vendored
@@ -6,7 +6,7 @@ Entry | Description
|
||||
-------- | -------------
|
||||
`dotfiles` | The dotfiles associated with this profile
|
||||
`import` | List of paths containing dotfile keys for this profile (absolute path or relative to the config file location; see [Import profile dotfiles from file](config-profiles.md#profile-import-entry)).
|
||||
`include` | Include all elements (dotfiles, actions, (dyn)variables, etc) from another profile (See [Include dotfiles from another profile](config-profiles.md#profile-include-entry))
|
||||
`include` | Include all elements (dotfiles, actions, (dyn)variables, etc) from another profile (See [Include dotfiles from another profile](config-profiles.md#profile-include-entry) and [meta profiles](howto/group-hosts.md))
|
||||
`variables` | Profile-specific variables (See [Variables](config-file.md#variables))
|
||||
`dynvariables` | Profile-specific interpreted variables (See [Interpreted variables](config-dynvars.md))
|
||||
`actions` | List of action keys that need to be defined in the **actions** entry below (See [actions](config-actions.md))
|
||||
@@ -39,7 +39,8 @@ If one profile is using the entire set of another profile, one can use
|
||||
the `include` entry to avoid redundancy.
|
||||
|
||||
Note that everything from the included profile is made available
|
||||
(actions, variables/dynvariables, etc).
|
||||
(actions, variables/dynvariables, etc). See also an example in
|
||||
[meta profiles](howto/group-hosts.md).
|
||||
|
||||
For example:
|
||||
```yaml
|
||||
|
||||
58
docs/howto/group-hosts.md
vendored
Normal file
58
docs/howto/group-hosts.md
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
# Group hosts in config and meta profiles
|
||||
|
||||
Let's consider the situation where you have multiple hosts from different distros and you
|
||||
want an easy way to structure your config file nicely but also simplify the use
|
||||
of templates (since multiple hosts in the same distro would share the same configs parts -
|
||||
or if branch in templates).
|
||||
|
||||
You define two types of profiles:
|
||||
|
||||
* **Meta profiles**: for example for distros it would be something like `os_arch`, `os_debian` and so on.
|
||||
These are never directly used for installing dotfiles but instead included by other profiles.
|
||||
* **Host profiles** (defaults to hostnames): the usual `home`, `office`, etc
|
||||
|
||||
Each *Host profile* would include a *meta profile* and inherit all its dotfiles as well as
|
||||
it variables. For example in the *meta profile* you would define variables like `distro: debian`
|
||||
that you could use in your templates with `{%@@ if distro == "debian" @@%}` to target all
|
||||
profiles that inherit from the same *meta profile*.
|
||||
|
||||
```yaml
|
||||
profiles:
|
||||
meta_base:
|
||||
dotfiles:
|
||||
- f_zshrc
|
||||
- f_zshrc
|
||||
os_arch:
|
||||
variables:
|
||||
distro: arch
|
||||
include:
|
||||
- meta-base
|
||||
os_debian:
|
||||
variables:
|
||||
distro: debian
|
||||
include:
|
||||
- meta-base
|
||||
home:
|
||||
include:
|
||||
- os_arch
|
||||
dotfiles:
|
||||
- f_vimrc
|
||||
office:
|
||||
include:
|
||||
- os_debian
|
||||
dotfiles:
|
||||
- f_something
|
||||
```
|
||||
|
||||
You then have the opportunity in your templates to do the following
|
||||
that would select the if branch for all profiles inheriting from
|
||||
a specific *meta profile*.
|
||||
```
|
||||
# zsh-syntax-highlighting
|
||||
# https://github.com/zsh-users/zsh-syntax-highlighting
|
||||
{%@@ if distro == "arch" @@%}
|
||||
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||
{%@@ elif distro == "debian" @@%}
|
||||
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||
{%@@ endif @@%}
|
||||
```
|
||||
Reference in New Issue
Block a user