Skip to main content

OS Specific Configuration

You can specify different behaviors per OS in all configuration files.

Rotz can differentiate between Windows, Linux and MacOS.

To specify OS Specific behavior you need to add top level keys named linux, windows, darwin (for MacOS) and general (applied to all OSs).

Example: defaults.yaml
windows:
installs:
cmd: scoop install {{ name }}
depends:
- scoop
- extras
darwin:
installs:
cmd: brew install {{ name }}
depends:
- brew
Example: neovim/dot.yaml
windows:
links:
ginit.vim: ~/AppData/Local/nvim/ginit.vim
init.vim: ~/AppData/Local/nvim/init.vim
global:
links:
ginit.vim: ~/.config/nvim/init.vim
init.vim: ~/.config/nvim/ginit.vim

You can also combine multiple OSs per key separating them with a |.

Example: defaults.yaml
windows:
installs:
cmd: scoop install {{ name }}
depends:
- scoop
- extras
darwin|linux:
installs:
cmd: brew install {{ name }}
depends:
- brew

Advanced Selection

Sometimes it's necessairy to differentiate between different versions of an OS.
For example, you might want to differentiate between Windows 10 and Windows 11 or between Ubuntu and Fedora.
Or maybe you want to do differnt things depending on the host name of your machine.

You can add a selector to the OS key to do this.

A selector looks like this: linux[some.key="some value"].

You can check for equality with =, for starts with with ^, for ends with with $, for contains with * and for not equals with !=.

SelectorDescriptionExample
=Check for equalitylinux[whoami.username="me"]
^=Check if the value starts with the given stringlinux[whoami.distro^="Ubuntu"]
$=Check if the value ends with the given stringlinux[whoami.realname$="Doe"]
*=Check if the value contains the given stringlinux[whoami.arch*="64"]
!=Check if the value is not equal to the given stringlinux[config.variables.profile!="work"]

You can also add multiple selectors to the same key linux[some.key="some value"][other.key="other value"].
And even combine them with | like linux[some.key="some value"]|windows[other.key="other value"].

Example: defaults.yaml
linux[whoami.distro^="Ubuntu"]:
installs: sudo apt install -y {{ name }}
linux[whoami.distro^="Arch"]:
installs: sudo pacman -S --noconfirm {{ name }}