Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: can autodetect OS and use the default package manager #44

Merged
merged 1 commit into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ clap = "3.2.20"
hcl-rs = "0.14.2"
indexmap = {version = "1.9.3", features = ["serde"]}
inquire = "0.6.2"
os-release = "0.1.0"
owo-colors = "3.5.0"
serde = "1.0.163"
spinners = "4.1.0"
Expand Down
247 changes: 37 additions & 210 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,30 @@

<img src="./preview.png" width="100%" style="margin-top: 20px; margin-bottom: 20px;" />

Crosup is a CLI tool to help you quickly setup your development environment on a new Chromebook (ChromeOS), Mac or any Debian-based Linux. It is designed to be simple and easy to use.

## 📦 Features
- [x] Install vscode
- [x] Install docker
- [x] Install nix
- [x] Install flox
- [x] Install devbox
- [x] Install homebrew
- [x] Install fish
- [x] Install ble.sh
- [x] Install atuin
- [x] Install tig
- [x] Install fzf
- [x] Install httpie
- [x] Install kubectl
- [x] Install minikube
- [x] Install tilt
- [x] Install zellij
- [x] Install ripgrep
- [x] Install fd
- [x] Install exa
- [x] Install bat
- [x] Install glow
- [x] Install devenv
- [x] Install neovim
- [x] Install zoxide
- [x] Install direnv
Crosup is a CLI tool to help you quickly setup your development environment on a new Chromebook (ChromeOS) or any Linux distribution. It is designed to be simple and easy to use.

## ✨ Features
- [x] Compatible with ChromeOS, Debian-based Linux, OpenSUSE, Fedora, RedHat, CentOS, Alpine and more!
- [x] Detects your OS and installs the appropriate tools
- [x] HCL/TOML configuration file
- [x] Install developer tools like docker, nix, devbox, homebrew, flox, fish, vscode, ble.sh, atuin, tig, fzf, httpie, kubectl, minikube, tilt, zellij, ripgrep, fd, exa, bat, glow, devenv and more!

## 🚚 Installation
```sh
curl -sSL https://raw.githubusercontent.com/tsirysndr/crosup/master/install.sh | bash
```

## 📦 Supported OS
- [x] ChromeOS (Debian Container)
- [x] Debian-based Linux
- [x] OpenSUSE
- [x] Fedora
- [x] RedHat
- [x] CentOS
- [x] Alpine
- [x] Arch
- [x] Gentoo

## 🚀 Usage
```
______ __ __
Expand All @@ -61,7 +52,7 @@ curl -sSL https://raw.githubusercontent.com/tsirysndr/crosup/master/install.sh |
\____/_/ \____/____/\____/ .___/
/_/

ChromeOS developer environment setup tool
Quickly install your development tools on your new Chromebook or any Linux distribution

USAGE:
crosup [SUBCOMMAND]
Expand All @@ -78,190 +69,26 @@ SUBCOMMANDS:
zellij, ripgrep, fd, exa, bat, glow, devenv
```

## 📝 Configuration
Crosup uses a configuration file to determine which tools to install. The default configuration is embedded in the binary, but you can generate a default configuration file (Crosfile.hcl) using the `crosup init` subcommand, you can specify the default format using the `--toml` flag.
## Minimal Configuration
This is a minimal configuration file to install vim and git:

```toml
# Crosfile.toml
[install.pkg.vim]
packages = ["vim"]
version_check = "vim --version"

Example configuration file in HCL format:

```hcl
# Crosfile.hcl
brew "install" {
pkg "minikube" {
preinstall = "sudo apt-get install -y qemu-system libvirt-clients libvirt-daemon-system"
postinstall = "sudo sed -i 's/#user = \"root\"/user = \"root\"/g' /etc/libvirt/qemu.conf\nsudo sed -i 's/#group = \"root\"/group = \"root\"/g' /etc/libvirt/qemu.conf\nsudo sed -i 's/#dynamic_ownership = 1/dynamic_ownership = 0/g' /etc/libvirt/qemu.conf\nsudo sed -i 's/#remember_owner = 1/remember_owner = 0/g' /etc/libvirt/qemu.conf"
version_check = "minikube version"
}

pkg "tilt" {
version_check = "tilt version"
}

pkg "kubernetes-cli" {
version_check = "kubectl version --client"
}

pkg "bat" {
version_check = "bat --version"
}

pkg "direnv" {
version_check = "direnv --version"
}

pkg "exa" {
version_check = "exa --version"
}

pkg "fd" {
version_check = "fd --version"
}

pkg "fzf" {
version_check = "fzf --version"
}

pkg "fish" {
version_check = "fish --version"
}

pkg "glow" {
version_check = "glow --version"
}

pkg "httpie" {
version_check = "http --version"
}

pkg "tig" {
version_check = "tig --version"
}

pkg "zellij" {
version_check = "zellij --version"
}

pkg "zoxide" {
version_check = "zoxide --version"
}

pkg "ripgrep" {
version_check = "rg --version"
}

pkg "neovim" {
version_check = "nvim --version"
}
}

git "install" {
repo "blesh" {
url = "https://github.com/akinomyoga/ble.sh.git"
install = "make -C ble.sh install PREFIX=~/.local"
preinstall = "sudo apt-get install -y gawk build-essential"
postinstall = "echo 'source ~/.local/share/blesh/ble.sh' >> ~/.bashrc"
install_check = "~/.local/share/blesh/ble.sh"
recursive = true
depth = 1
shallow_submodules = true
}
}

nix "install" {
pkg "flox" {
impure = true
experimental_features = "nix-command flakes"
accept_flake_config = true
preinstall = "echo 'extra-trusted-substituters = https://cache.floxdev.com' | sudo tee -a /etc/nix/nix.conf && echo 'extra-trusted-public-keys = flox-store-public-0:8c/B+kjIaQ+BloCmNkRUKwaVPFWkriSAd0JJvuDu4F0=' | sudo tee -a /etc/nix/nix.conf"
flake = "github:flox/floxpkgs#flox.fromCatalog"
version_check = ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && flox --version"
}

pkg "cachix" {
flake = "github:cachix/cachix"
}

pkg "devenv" {
accept_flake_config = true
preinstall = "echo \"trusted-users = root $USER\" | sudo tee -a /etc/nix/nix.conf\nsudo pkill nix-daemon\ncachix use devenv"
flake = "github:cachix/devenv/latest"
depends_on = [
"cachix"
]
version_check = ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && devenv version"
}
}

curl "install" {
script "devbox" {
url = "https://get.jetpack.io/devbox"
version_check = "devbox version"

env {
FORCE = "1"
}

shell = "bash"
depends_on = [
"nix"
]
}

script "atuin" {
url = "https://raw.githubusercontent.com/ellie/atuin/main/install.sh"
version_check = "atuin --version"
shell = "bash"
}

script "nix" {
url = "https://install.determinate.systems/nix"
enable_sudo = true
version_check = ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix --version"
args = "install --no-confirm"
}

script "homebrew" {
url = "https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh"
postinstall = "echo 'eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)' >> ~/.bashrc"
version_check = "brew --version"

env {
NONINTERACTIVE = "true"
}

shell = "bash"
}
}

apt "install" {
pkg "docker" {
gpg_key = "https://download.docker.com/linux/debian/gpg"
gpg_path = "/etc/apt/keyrings/docker.gpg"
setup_repository = "echo \"deb [arch=\"$(dpkg --print-architecture)\" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \"$(. /etc/os-release && echo \"$VERSION_CODENAME\")\" stable\" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null"
apt_update = true
packages = [
"docker-ce",
"docker-ce-cli",
"containerd.io",
"docker-buildx-plugin",
"docker-compose-plugin"
]
depends_on = [
"ca-certificates",
"curl",
"gnupg"
]
postinstall = "sudo usermod -aG docker $USER && newgrp docker"
version_check = "docker --version"
}

pkg "vscode" {
url = "https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64"
version_check = "code --version"
}
}
[install.pkg.git]
packages = ["git"]
version_check = "git --version"
```

Example of a Crosfile.toml for a Debian-based system:
When you run `crosup install`, it will detect your OS and install the appropriate tools using the default package manager.

## 📝 Configuration
Crosup uses a configuration file to determine which tools to install. The default configuration is embedded in the binary, but you can generate a default configuration file (Crosfile.hcl) using the `crosup init` subcommand, you can specify the default format using the `--toml` flag.

Example of a Crosfile.toml (`crosup init --toml`) for a Debian-based system:

```toml
# Crosfile.toml
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anyhow::Error;
use crate::{config::verify_if_config_file_is_present, graph::build_installer_graph};

pub fn execute_install(tool: Option<String>) -> Result<(), Error> {
let config = verify_if_config_file_is_present()?;
let mut config = verify_if_config_file_is_present()?;

match tool {
Some(tool) => {
Expand All @@ -14,7 +14,7 @@ pub fn execute_install(tool: Option<String>) -> Result<(), Error> {
false => vec![tool.as_str()],
};
for tool in tools {
let (graph, installers) = build_installer_graph(&config);
let (graph, installers) = build_installer_graph(&mut config);
let tool = installers
.into_iter()
.find(|installer| installer.name() == tool)
Expand All @@ -24,7 +24,7 @@ pub fn execute_install(tool: Option<String>) -> Result<(), Error> {
}
}
None => {
let (graph, _) = build_installer_graph(&config);
let (graph, _) = build_installer_graph(&mut config);
graph.install_all()?;
}
}
Expand Down
Loading