Support lists for "installs"
icepuma opened this issue ยท 5 comments
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:
- I have
config.yaml
with variables
variables:
packages:
darwin:
- visual-studio-code
- vim
- rustup
linux:
- vscode
- emacs
- golang
- I have a
dot.yaml
where I want to install a set of packages
darwin:
installs:
cmd: brew install {{ <package> }}
# packages: {{ variables.darwin }}
depends:
- brew
linux:
installs:
cmd: yay install {{ <package> }}
# packages: {{ variables.darwin }}
depends:
- yay
- As
rotz
supports arrays, there could be apackages
property forinstalls
to install more than one package withcmd
Does this make any sense?
I'm happy to discuss the idea or answer any follow-up questions :)
Cheers
Stefan
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
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
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.
I thought as much ๐ If that works for you I'll close the issue
Yeah sure, thanks for the suggestions :)