volllly / rotz

Fully cross platform dotfile manager and dev environment bootstrapper written in Rust.
https://volllly.github.io/rotz/
MIT License
348 stars 9 forks source link

Support lists for "installs" #302

Closed icepuma closed 10 months ago

icepuma commented 10 months ago

Hey, I really like the idea of rotz. I saw the example for installs and was missing the ability to install a list of tools.

Let me outline my idea:

Does this make any sense?

I'm happy to discuss the idea or answer any follow-up questions :)

Cheers Stefan

volllly commented 10 months ago

Hey, something like this is already possible in two ways 😁

Option 1

One way is to basically do it like you suggested using variables and templates:

darwin:
  installs:
    cmd: |
      {{ #each config.variables.packages.darwin }}
        brew install {{this}}
      {{ /each }}
    depends:
      - brew
linux:
  installs:
    cmd: |
      {{ #each config.variables.packages.linux }}
        yay install {{this}}
      {{ /each }}
    depends:
      - yay

This works since the cmd key is just a shell script.

You could actually do it even more simple just like that:

darwin:
  installs:
    cmd: |
      brew install visual-studio-code
      brew install vim
      brew install rustup
    depends:
      - brew
linux:
  installs:
    cmd: |
      yay install vscode
      yay install emacs
      yay install golang
    depends:
      - yay

Option 2.a

The second way works using defaults files.

It is more complex but has the advantage of each application being split up into its own folder (but that's personal perference I guess ^^)

In the repo you have a file structure like that:

├── visual-studio-code
│   ├── ...
│   └── dot.yaml
├── vim
│   ├── ...
│   └── dot.yaml
├── rustup
│   ├── ...
│   └── dot.yaml
├── emacs
│   ├── ...
│   └── dot.yaml
├── golang
│   ├── ...
│   └── dot.yaml
└── defaults.yaml

In the defaults.yaml file you specify the default install commands:

darwin:
  installs:
    cmd: brew install {{ name }}
    depends:
      - brew
linux:
  installs:
    cmd: yay install {{ name }}
    depends:
      - yay

now you setup the dot.yaml files

vim/dot.yaml

linux:
  installs: false # by setting this to false it will not use the default on linux and will not be installed on linux

rustup/dot.yaml

linux:
  installs: false

emacs/dot.yaml

darwin:
  installs: false # by setting this to false it will not use the default on macos and will not be installed on macos

golang/dot.yaml

darwin:
  installs: false

visual-studio-code/dot.yaml

linux:
  installs: yay install vscode # Override the command because the package name is different on linux

Option 2.b

Basically the same thing as option 2.a but using multiple defaults.yaml files for each OS.

├── visual-studio-code
│   ├── ...
│   └── dot.yaml
├── darwin
│   ├── vim
│   │   ├── ...
│   │   └── dot.yaml
│   ├── rustup
│   │   ├── ...
│   │   └── dot.yaml
│   └── defaults.yaml
└── linux
    ├── emacs
    │   ├── ...
    │   └── dot.yaml
    ├── golang
    │   ├── ...
    │   └── dot.yaml
    └── defaults.yaml

And the darwin/defaults.yaml looks like this:

darwin:
  installs:
    cmd: brew install {{ name }}
    depends:
      - brew

the linux/defaults.yaml looks like this:

linux:
  installs:
    cmd: yay install {{ name }}
    depends:
      - yay

and the exception is the visual-studio-code/dot.yaml

darwin:
  installs: brew install visual-studio-code
linux:
  installs: yay install vscode
volllly commented 10 months ago

Something that would solve the problem of different package names in the second option would be to add support for a name key to the dot.yaml files where you could overwrite the package name 🤔

something like:

vscode/dot.yaml

darwin:
  name: visual-studio-code
linux:
  name: vscode

defaults.yaml

darwin:
  installs:
    cmd: brew install {{ name }}
    depends:
      - brew
linux:
  installs:
    cmd: yay install {{ name }}
    depends:
      - yay
icepuma commented 10 months ago

Hey, Option 1 seems more like the thing I want. Option 2... is cool, but I want to maintain a list of all my packages in a central place.

volllly commented 10 months ago

I thought as much 😁 If that works for you I'll close the issue

icepuma commented 10 months ago

Yeah sure, thanks for the suggestions :)