rotz

repository·main·Indexed 19 days ago

https://github.com/volllly/rotz

A fully cross-platform dotfile manager and development environment bootstrapper written in Rust. Rotz enables users to link configuration files, automate application installation, and manage settings across Linux, MacOS, and Windows using yaml, toml, or json configuration files.

Tokens
11.2K
Snippets
52
Records
69
Agent score
64%

What's inside rotz

  1. Use `defaults.yaml` to provide fallback values

    main

    You can define a defaults.yaml file in any folder within your repository. These files provide default values that are automatically applied to subdirectories when keys are missing from the local dot.yaml files. This allows you to define common configurations at a higher level in the directory tree and only override specific keys in nested dot.yaml files.

    # Example: defaults.yaml in a parent directory
    installs:
      cmd: 'scoop install {{ name }}'
      depends:
        - 'scoop'
        - 'extras'
  2. Structure managed application dotfiles

    main

    Each application managed by Rotz must reside in a subfolder within your dotfiles repository. This subfolder must contain the actual dotfiles (e.g., settings.json) and a metadata file named dot.yaml, dot.toml, or dot.json.

    The dot.* file provides the necessary instructions for Rotz on how to install the application and where to create the symbolic links for the dotfiles.

    Supported Directory Structures

    Standard Structure:

    └── vscode
        ├── dot.yaml
        ├── keybindings.json
        └── settings.json

    Nested Structure: Rotz supports nesting dotfiles within parent directories (e.g., grouping editors together).

    └── editors
        ├── vscode
        │   ├── dot.yaml
        │   ├── keybindings.json
        │   └── settings.json
        └── neovim
            ├── dot.yaml
            └── init.lua
    # Example of a dot.yaml structure inside a subfolder
    └── vscode
        ├── dot.yaml
        ├── keybindings.json
        └── settings.json
  3. Use template strings in default files

    main

    When defining values in defaults.yaml, you can use template strings like {{ name }}. The {{ name }} placeholder is automatically substituted with the name of the application, which is defined as the name of the folder containing the dot.yaml file. For more complex logic, refer to the templating documentation.

    # If this is in a folder named 'myapp', {{ name }} becomes 'myapp'
    cmd: 'scoop install {{ name }}'
  4. Use advanced selectors for OS-specific configuration

    main

    For more granular control, you can append a selector to an OS key to differentiate between OS versions, distributions, or machine properties.

    A selector follows the pattern: os_key[property.path="value"].

    Supported operators:

    • =: Equality (linux[whoami.username="me"])
    • ^=: Starts with (linux[whoami.distro^="Ubuntu"])
    • $=: Ends with (linux[whoami.realname$="Doe"])
    • *=: Contains (linux[whoami.arch*="64"])
    • !=: Not equal to (linux[config.variables.profile!="work"])

    You can chain multiple selectors together (e.g., linux[key1="val1"][key2="val2"]) or combine different OS selectors using the | operator.

    ['linux[whoami.distro^="Ubuntu"]']
    installs = 'sudo apt install -y {{ name }}'
    
    ['linux[whoami.distro^="Arch"]']
    installs = 'sudo pacman -S --noconfirm {{ name }}'
  5. Install Rotz

    main

    Rotz can be installed on various platforms using Homebrew, Scoop, Cargo, or via installer scripts.

    Homebrew (Linux and MacOS)

    brew install volllly/tap/rotz

    Scoop (Windows)

    scoop bucket add volllly https://github.com/volllly/scoop-bucket
    scoop install volllly/rotz

    Cargo (Cross-platform)

    If you have Rust installed, you can use Cargo. By default, Rotz supports yaml, toml, and json configuration files. If you want to reduce the binary size by supporting only one specific format, use the --features flag during installation.

    cargo install rotz

    To install with only specific filetype support:

    cargo install rotz --no-default-features --features toml
    # OR
    cargo install rotz --no-default-features --features json

    Installer Scripts

    Linux/MacOS:

    curl -fsSL volllly.github.io/rotz/install.sh | sh

    Windows (PowerShell):

    irm volllly.github.io/rotz/install.ps1 | iex
    brew install volllly/tap/rotz
  6. Build the Rotz website for production

    main

    To generate the static content for the website, run yarn build. The resulting static files will be located in the build directory and can be hosted using any static content hosting service.

    $ yarn build
  7. Get started with Rotz

    main

    Rotz is a cross-platform dotfile manager and dev environment bootstrapper. It provides three main functionalities:

    1. Linking dotfiles: Connect files from a common repository to your system.
    2. Installing applications: Bootstrap a new or empty machine with necessary tools.
    3. Cross-platform configuration: Manage settings across different operating systems.

    Basic Workflow

    1. Clone your dotfiles repository: Use the clone command to bring your existing configuration into Rotz.
    2. Bootstrap your environment: Use install to set up the applications required for your development environment.
    3. Link your dotfiles: Use link to map your configuration files to the correct locations on your system.
    # Clone a repository
    rotz clone git@github.com:<user>/<repo>.git
    
    # Bootstrap applications
    rotz install
    
    # Link dotfiles
    rotz link
    rotz clone git@github.com:<user>/<repo>.git
  8. Use OS-specific defaults in a repository config

    main

    To provide default settings for anyone using your repository, you can place a configuration file (e.g., .dotfiles/config.yaml) inside the repo. This file can define platform-specific overrides that are automatically superseded by the user's local machine configuration.

    Supported platform keys:

    • global: Used if no platform-specific key is matched.
    • windows: Windows-specific settings.
    • linux: Linux-specific settings.
    • darwin: MacOS-specific settings.
    # .dotfiles/config.yaml
    global:
      link_type: 'symbolic'
    windows:
      dotfiles: '<windowsDefault>'
    linux:
      dotfiles: '<linuxDefault>'
    darwin:
      dotfiles: '<macosDefault>'
  9. Use relative or absolute paths for nested dependencies

    main

    When dotfiles are organized in subdirectories, you can specify dependencies using paths. These paths can be:

    • Relative paths: Relative to the current dot.yaml file.
    • Absolute paths: Relative to the root of the dotfiles repository.

    Example of a relative dependency path:

    depends:
      - '../../other/directory'