#chrome-os #nix #chromebook #docker #homebrew #linux-distro #cli-tool

crosup-core

一个简单的命令行工具,用于快速在Chromebook(ChromeOS)或任何Linux发行版上设置开发环境

10个版本

0.2.0 2023年10月7日
0.1.9 2023年6月22日

#10 in #chromebook

Download history 5/week @ 2024-03-08 2/week @ 2024-03-15 11/week @ 2024-03-29 5/week @ 2024-04-05

每月61次下载
crosup中使用

MIT许可

150KB
4K SLoC

Crosup 🐧 💻 🚀 ✨

release License: MIT

Crosup是一个命令行工具,帮助您快速在新Chromebook(ChromeOS)或任何Linux发行版上设置开发环境。它设计得简单易用。

✨ 特性

  • 兼容ChromeOS、基于Debian的Linux、OpenSUSE、Fedora、RedHat、CentOS、Alpine等!
  • 检测您的操作系统并安装适当的工具
  • HCL/TOML配置文件
  • 安装开发者工具,如docker、nix、devbox、homebrew、floxfish、vscode、ble.sh、atuin、tig、fzf、httpie、kubectl、minikube、tilt、zellij、ripgrep、fd、exa、bat、glow、devenv等!

🚚 安装

bash <(curl -sSL https://raw.githubusercontent.com/tsirysndr/crosup/master/install.sh)

从源代码编译

git clone https://github.com/tsirysndr/crosup.git
cd crosup
nix develop --experimental-features "nix-command flakes"
cargo install --path crates/cli

📦 支持的操作系统

  • ChromeOS(Debian容器)
  • 基于Debian的Linux
  • OpenSUSE
  • Fedora
  • RedHat
  • CentOS
  • Alpine
  • Arch
  • Gentoo
  • Slackware

🚀 使用方法

             ______                __  __
            / ____/________  _____/ / / /___
           / /   / ___/ __ \/ ___/ / / / __ \
          / /___/ /  / /_/ (__  ) /_/ / /_/ /
          \____/_/   \____/____/\____/ .___/
                                    /_/

Quickly install your development tools on your new Chromebook or any Linux distribution

USAGE:
    crosup [SUBCOMMAND]

OPTIONS:
    -h, --help       Print help information
    -V, --version    Print version information

SUBCOMMANDS:
    add        Add a new tool to the configuration file
    diff       Show the difference between the current configuration and the previous one
    help       Print this message or the help of the given subcommand(s)
    history    Show the change history of the configuration file
    init       Generate a default configuration file
    install    Install developer tools, e.g. docker, nix, devbox, homebrew, fish, vscode, ble.sh
                   ...
    search     Search for a package in the nixpkgs repository

🛠️ 最小配置

这是一个用于安装vim和git的最小配置文件

# Crosfile.toml
packages = [
  "vim",
  "git"
]

当您运行 crosup install 时,它将检测您的操作系统,并使用nix home-manager 在您的系统上安装适当的工具。

📝 高级配置

Crosup使用配置文件来确定要安装哪些工具。默认配置嵌入在二进制文件中,但您可以使用 crosup init 子命令生成默认配置文件(Crosfile.hcl),您可以使用 --toml 标志指定默认格式。

Debian系统Crosfile.toml的示例(crosup init --toml

# Crosfile.toml
[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
            sudo sed -i 's/#group = \"root\"/group = \"root\"/g' /etc/libvirt/qemu.conf
            sudo sed -i 's/#dynamic_ownership = 1/dynamic_ownership = 0/g' /etc/libvirt/qemu.conf
            sudo sed -i 's/#remember_owner = 1/remember_owner = 0/g' /etc/libvirt/qemu.conf"""

[brew.install.pkg.tilt]

[brew.install.pkg.kubernetes-cli]
version_check = "kubectl"

[brew.install.pkg.bat]

[brew.install.pkg.direnv]

[brew.install.pkg.exa]

[brew.install.pkg.fd]

[brew.install.pkg.fzf]

[brew.install.pkg.fish]

[brew.install.pkg.glow]

[brew.install.pkg.httpie]
version_check = "http"

[brew.install.pkg.tig]

[brew.install.pkg.zellij]

[brew.install.pkg.zoxide]

[brew.install.pkg.ripgrep]
version_check = "rg"

[brew.install.pkg.neovim]
version_check = "nvim"

[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"

[nix.install.pkg.cachix]
flake = "github:cachix/cachix"

[nix.install.pkg.devenv]
accept_flake_config = true
preinstall = """
echo \"trusted-users = root $USER\" | sudo tee -a /etc/nix/nix.conf
sudo pkill nix-daemon
cachix use devenv"""
flake = "github:cachix/devenv/latest"
depends_on = ["cachix"]

[curl.install.script.devbox]
url = "https://get.jetpack.io/devbox"
shell = "bash"
depends_on = ["nix"]

[curl.install.script.devbox.env]
FORCE = "1"

[curl.install.script.atuin]
url = "https://raw.githubusercontent.com/ellie/atuin/main/install.sh"
shell = "bash"

[curl.install.script.nix]
url = "https://install.determinate.systems/nix"
enable_sudo = true
args = "install --no-confirm"

[curl.install.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"
shell = "bash"

[curl.install.script.homebrew.env]
NONINTERACTIVE = "true"

[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"

[apt.install.pkg.vscode]
url = "https://vscode.js.cn/sha/download?build=stable&os=linux-deb-x64"
version_check = "code"

🚀 作为GitHub Action

您可以将crosup用作GitHub Action,在您的CI/CD管道上安装开发者工具。

name: Setup Crosup
on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master
  workflow_dispatch:

jobs:
  setup-crosup:
    runs-on: ubuntu-latest
    continue-on-error: true
    steps:
      - name: Install Nix
        uses: DeterminateSystems/nix-installer-action@v4
      - name: Setup Crosup
        uses: tsirysndr/setup-crosup@v1
        with:
          version: 'v0.5.0'
          # Add packages to install here
          packages: |
            deno
            zig
      - name: Verify Crosup
        run: crosup --version
      - name: Verify Deno
        run: deno --version
      - name: Verify Zig
        run: zig version

有关此操作的输入和输出的完整文档,请参阅 action.yml

🤝 贡献

欢迎贡献、问题和特性请求!有关更多信息,请参阅 CONTRIBUTING

📝 许可证

MIT

依赖项

~32–50MB
~1M SLoC