Skip to content

A streamlined installation of Homebrew on Synology NAS, featuring libraries and packages to help you install what you need without conflicts. Perfect for enhancing your Synology NAS with additional software and tools.

License

Notifications You must be signed in to change notification settings

MrCee/Synology-Homebrew

Repository files navigation

Synology-Homebrew + Neovim!

Introduction

Simplify the installation of Homebrew on Synology NAS devices running DSM 7.2 or later with this script. Our repository streamlines the process, ensuring comprehensive coverage of available packages for macOS/Linux on your Synology NAS.

Why Homebrew on Synology NAS?

Homebrew, a package manager for macOS and Linux, unlocks a vast ecosystem of modern software and libraries for your Synology NAS. Dive into the richer features as mentioned below...

Key Features

  • Installation Options: Choose between a Minimal or Advanced installation. If you just want homebrew to work then Minimal install is for you.
  • Profile Creation: Configures the default Synology ash/sh profile and newly installed zsh to work seamlessly with Homebrew.
  • Synology Integration: Resolves conflicts with existing Synology packages without removing anything from your NAS.
  • Easy Uninstall: Revert to the original state of your NAS with the included uninstall script.

Prerequisites

Before you begin, ensure you have the following:

  1. Synology NAS Requirements:

    • A Synology NAS running DSM 7.2 or later.
    • SSH access to your NAS.
    • User homes enabled on your NAS.
    • A scheduled task which ensures Homebrew is mounted after each restart. Detailed instructions are provided below.
  2. Git Installation:

    • Git is necessary for the installation process and can be installed via the Package Center Manager from SynoCommunity. During Homebrew installation, Git will be updated to the latest version in Homebrew's path. If desired, you can uninstall the Synology Package Center version of Git afterwards.
  3. iTerm2 Configuration:

    • iTerm2 (or alternative other than the default MacOS Terminal.app) running on your local machine with compatible Nerd Fonts and a color profile for an improved visual experience.
      Refer to the iTerm2 Configuration Guide for a quick setup.

Installation

Download and Run in one command: SSH into your Synology NAS running DSM 7.2 or above, and copy/paste the following command to download into your home directory and automatically execute the script.

git clone https://github.com/MrCee/Synology-Homebrew.git ~/Synology-Homebrew && \
~/Synology-Homebrew/install-synology-homebrew.sh

Select your install type:

1) Minimal Install: This will provide the homebrew basics, ignore packages in config.yaml, leaving the rest to you.

You can also use this option to uninstall packages in config.yaml installed by option 2 by running the script again.

2) Advanced Install: Full setup includes packages in config.yaml

Recommended if you want to get started with Neovim or install some of the great packages listed.

Both install types include the following essential packages to ensure Homebrew runs smoothly on Synology:

git, ruby, glibc, gcc, clang-build-analyzer (which includes latest python & pip), yq, zsh, oh-my-zsh.

Configuration for Advanced install (config.yaml)

To manage packages, plugins, and themes, edit the config.yaml file and set the install flag to one of three options: true, false, or skip.

  • true: Install the package, plugin, or theme.
  • false: Uninstall the package, plugin, or theme.
  • skip: Do nothing, leaving the current state unchanged.

Plugins and themes can be defined under the plugins section. Plugin names will be updated to reflect the last part of the URL for consitency.

config.yaml example

The below is a snippet of how config.yaml should be formatted. Please see the file downloaded from this repository for the full scope.

packages:
  make:
    install: "true"
    aliases: []
    eval: []
  jq:
    install: "true"
    aliases: []
    eval: []
  perl:
    install: "true"
    aliases: []
    eval:
      - "perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=$HOME/perl5"
  neovim:
    install: "true"
    aliases:
      vim: "nvim"
    eval: []
  stow:
    install: "skip"
    aliases: []
    eval: []
  fzf:
    install: "true"
    aliases: []
    eval:
      - "fzf --zsh"
  bat:
    install: "true"
    aliases:
      cat: "bat --paging=never"
    eval: []
  eza:
    install: "true"
    aliases:
      ls: "eza --color=always --group-directories-first --icons"
      ll: "eza -la --icons --octal-permissions --group-directories-first --icons"
      l: "eza -bGF --header --git --color=always --group-directories-first --icons"
      llm: "eza -lbGd --header --git --sort=modified --color=always --group-directories-first --icons"
      la: "eza --long --all --group --group-directories-first"
      lx: "eza -lbhHigUmuSa@ --time-style=long-iso --git --color-scale --color=always --group-directories-first --icons"
      lS: "eza -1 --color=always --group-directories-first --icons"
      lt: "eza --tree --level=2 --color=always --group-directories-first --icons"
      l.: "eza -a | grep -E '^\\.'"
    eval: []
  thefuck:
    install: "true"
    aliases: []
    eval:
      - "thefuck --alias"
  zoxide:
    install: "true"
    aliases:
      cd: "z"
    eval:
      - "zoxide init zsh"
  jesseduffield/lazygit/lazygit:
    install: "true"
    aliases:
      lg: "lazygit"
    eval: []
plugins:
  powerlevel10k:
    install: "true"
    url: "https://github.com/romkatv/powerlevel10k"
    directory: "~/.oh-my-zsh/custom/themes/powerlevel10k"
    aliases: []
    eval: []
  kickstart.nvim:
    install: "true"
    url: "https://github.com/nvim-lua/kickstart.nvim"
    directory: "~/.config/nvim-kickstart"
    aliases:
      nvim: "NVIM_APPNAME=\"nvim-kickstart\" nvim"
    eval: []

Installed packages

Modify packages to be installed by editing config.yaml and setting the install flag to true, false, or skip.

Package Description Dependency
brew Homebrew - The Missing Package Manager now for MacOS & Linux. Essential for: Synology-Homebrew
git Latest version replaces Synology Package Centre version. Essential for: Synology-Homebrew
ruby Latest version replaces Synology Package Centre version. Essential for: Synology-Homebrew
zsh UNIX shell (command interpreter). Essential for: Synology-Homebrew
python3 / pip3 Installed with clang-build-analyzer. Latest version 3.12.3 Essential for: Synology-Homebrew
glibc The GNU C Library - The project provides the core libraries for the GNU system. Essential for: Synology-Homebrew
gcc GNU compiler collection. Essential for: Synology-Homebrew
clang installed with clang-build-analyzer containing many essential tools. Essential for: Synology-Homebrew
oh-my-zsh Oh My Zsh is a delightful, open source, community-driven framework for managing your Zsh configuration. Essential for: Synology-Homebrew, zsh
jq Latest version of Lightweight and flexible command-line JSON processor Essential for: Synology-Homebrew
make Utility for directing compilation. Essential for: neovim plugins
node JavaScript runtime environment. Essential for: neovim
neovim Hyperextensible Vim-based text editor. Recommended for: Synology
powerlevel10k A theme for zsh. Recommended for: oh-my-zsh
zsh-syntax-highlighting A plugin for zsh. Recommended for: oh-my-zsh
zsh-autosuggestions A plugin for zsh. Recommended for: oh-my-zsh
ripgrep Ripgrep is a line-oriented search tool that recursively searches the current directory for a regex pattern. Essential for: neovim, telescope, fzf
fd Simple, fast and user-friendly alternative to find. Essential for: neovim, telescope
fzf A command-line fuzzy finder. Essential for: neovim, telescope
fzf-git.sh Bash and zsh key bindings for Git objects. Recommended for: neovim, telescope, fzf
bat A cat clone with syntax highlighting and Git integration. Recommended for: zsh, neovim
git-delta Language syntax highlighting for diff using a Levenshtein edit inference algorithm. Recommended for: neovim
eza A modern, maintained replacement for the venerable file-listing command-line program ls Recommended for: zsh, neovim
tldr The tldr-pages project is a collection of community-maintained help pages for command-line tools Recommended for: neovim
thefuck A magnificent app that corrects errors in previous console command. Recommended for: zsh
kickstart.nvim A starting point for Neovim. Optional for: neovim
perl Highly capable, feature-rich programming language. Essential for: stow
stow GNU Stow: Organize software neatly under a single directory tree. Optional
zoxide Zoxide is a smarter cd command, inspired by z and autojump Recommended for: zsh
lazygit AMAZING Simple terminal UI for git commands Recommended for: zsh, neovim

For a full list of dependancies installed, run: brew deps --installed after installation.

Neovim

Neovim (nvim) is ready to go with essential requirements configured within a separate file nvim_config.sh in which you can run indepenently to enable clipboard and further required files. This includes:

  • Enable clipboard over SSH using OSC52 for all nvim configurations stored or symlinked in ~/.config.
  • Linting Python with pip3 install pynvim.
  • Installing neovim gem.
  • Updating outdated gems.
  • Adding fzf-git.sh with Git key bindings to ~/.scripts directory.

Kickstart Neovim with Lazy (optional)

In the plugins section of config.yaml, set kickstart.nvim to true to install and configure Neovim with kickstart.nvim. This provides a lazy configuration with everything working out of the box. It will be installed to the specified directory in config.yaml with a backup of any existing config to your home folder.

To switch between Neovim configurations easily, use aliases in ~/.zshrc and swap to your config:

alias nvim="NVIM_APPNAME=\"nvim-kickstart\" nvim"

# or for example...

alias nvim="NVIM_APPNAME=\"nvim-mrcee\" nvim"

See kickstart.nvim provided in the config.yaml example above.

If no alias is set, Neovim will attempt to use the default nvim config location ~/.config/nvim

Run :checkhealth in Neovim after installation to see more detail about any further plugins you may need.

Customizing Your zsh

The Synology-Homebrew + Neovim setup comes pre-configured with a sleek Zsh theme and several useful plugins to enhance your command-line experience. Customize your zsh with ease using the p10k configure command and enjoy a fully tailored terminal environment.

Synology Task Scheduler to Persist Installation after Restart

To ensure the Homebrew directory is mounted after each restart, add a Triggered Task with a User-defined script. Go to Control Panel > Task Scheduler, click Create, and select Triggered Task >> User-defined Script and enter the following...

1st tab:

  • Task name: "Homebrew Boot"
  • User: root
  • Event: Boot-up
  • Enabled: True

2nd tab:

  • Paste the following User-defined script...
#!/bin/bash
[[ ! -d /home ]] && mkdir /home
mount -o bind "/volume1/homes" /home

TL;TR

Portable Code (Limited)

Regex and functions.sh Explained

If you would like to use parts of this code across different environments, such as macOS (a BSD-based Unix-like operating system), you'll appreciate the addition of the functions.sh file.

This file houses functions designed to standardise commands used in Synology NAS (GNU Linux), ensuring compatibility and portability across platforms, particularly with utilities like sed.

This approach simplifies the process of adapting similar code to other systems outside of Synology NAS.

Please Note: install-synology-homebrew.sh should only be run on Synology NAS.

Usage and Contributions

Refer to Homebrew documentation for usage instructions. Contributions are welcome! Open an issue or submit a pull request on GitHub for feedback or suggestions.

Disclaimer and License

This script is provided as-is without any warranty. Review and understand the script's changes to your system before running it. This project is licensed under the MIT License.

Acknowledgements

Thanks to the many people and teams that contribute to the packages installed by this script, the GitHub & Synology community, and some of the best on youtube. @ogerardin, @AppleBoiy, @josean-dev, @tjdevries.

About

A streamlined installation of Homebrew on Synology NAS, featuring libraries and packages to help you install what you need without conflicts. Perfect for enhancing your Synology NAS with additional software and tools.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages