feat: macos support

This commit is contained in:
Tine Jozelj 2024-04-21 19:55:27 +02:00
parent 066d0871bb
commit 5a10ec49a8
5 changed files with 132 additions and 94 deletions

View file

@ -1,8 +1,7 @@
#!/bin/bash #!/usr/bin/env bash
REPO_DIR=$(dirname $(readlink -f $0)) REPO_DIR=$(dirname $(readlink -f $0))
HOME_DIR=${HOME} HOME_DIR=${HOME}
OS_RELEASE=$(cat /etc/os-release | grep -E "^ID=" | cut -d= -f2)
echo_header() { echo_header() {
bold=$(tput bold) bold=$(tput bold)
@ -44,4 +43,3 @@ while [[ $# -gt 0 ]]; do
;; ;;
esac esac
done done
echo_header "== DotFiles with GUI: $GUI and ENV: $ENVIRONMENT"

90
install-linux.sh Executable file
View file

@ -0,0 +1,90 @@
#!/usr/bin/env bash
set -euo pipefail
source common.sh
OS_RELEASE=$(cat /etc/os-release | grep -E "^ID=" | cut -d= -f2)
# Install basic packages.
# Most other packages are installed via Home Manager.
# Or for GUI applications, they are installed via flatpak.
if [ "$OS_RELEASE" = "fedora" ]; then
echo_header "== Detected Fedora"
rpm-ostree install --idempotent --apply-live --allow-inactive -y \
git git-lfs zsh curl htop wget
elif [ "$OS_RELEASE" = "ubuntu" ]; then
echo_header "== Detected Ubuntu"
sudo apt-get update
sudo apt-get install -y \
git git-lfs zsh curl htop wget
fi
if [ "$GUI" = "YES" ]; then
if [ "$OS_RELEASE" = "fedora" ]; then
echo_header "==[fedora] Installing GUI applications"
rpm-ostree install --idempotent --apply-live --allow-inactive -y \
kitty \
gphoto2 v4l2loopback ffmpeg \
ddcutil
echo_header "==[fedora] Installing docker"
cat <<EOF | sudo tee /etc/yum.repos.d/docker.repo >/dev/null
[docker-ce-stable]
name=Docker CE Stable - \$basearch
baseurl=https://download.docker.com/linux/fedora/\$releasever/\$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://download.docker.com/linux/fedora/gpg
EOF
rpm-ostree install --idempotent --apply-live --allow-inactive -y \
docker-ce docker-ce-cli \
containerd.io \
docker-buildx-plugin \
docker-compose-plugin
sudo usermod -aG docker $USER
echo "== Docker installed, restart will be needed to take effect."
elif [ "$OS_RELEASE" = "ubuntu" ]; then
echo_header "==[ubuntu] Installing GUI applications"
sudo apt-get update
sudo apt-get install -y \
kitty \
gphoto2 ffmpeg \
ddcutil
echo_header "==[ubuntu] Installing flatpak"
sudo apt-get install -y \
flatpak gnome-software-plugin-flatpak
echo_header "==[ubuntu] Installing docker"
sudo apt-get update
sudo apt-get install ca-certificates
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" |
sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo usermod -aG docker $USER
echo "== Docker installed, restart will be needed to take effect."
fi
echo_header "== Installing flatpaks"
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install -y --user \
com.bitwarden.desktop \
md.obsidian.Obsidian \
org.mozilla.firefox \
org.mozilla.Thunderbird \
org.gnome.Builder \
com.vscodium.codium
echo_header "== Installing fonts"
HOME_FONTS_DIR="${HOME_DIR}/.local/share/fonts"
mkdir -p ${HOME_FONTS_DIR}
rm -rf ${HOME_FONTS_DIR}/dotfiles-fonts
git clone --depth 1 git@github.com:mentos1386/dotfiles-fonts.git ${HOME_FONTS_DIR}/dotfiles-fonts
fc-cache
fi

21
install-macos.sh Executable file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail
source common.sh
echo_header "== Installing homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
export PATH="/opt/homebrew/bin:$PATH"
echo_header "== Installing CLI tools"
brew install git git-lfs zsh curl htop wget
echo_header "== Installing GUI tools"
brew install --cask --adopt \
kitty \
orbstack \
firefox \
bitwarden \
obsidian \
thunderbird \
visual-studio-code

View file

@ -1,94 +1,22 @@
#!/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
source common.sh source common.sh
echo_header "== DotFiles with GUI: $GUI and ENV: $ENVIRONMENT"
# Install basic packages. if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Most other packages are installed via Home Manager. echo_header "== Detected linux"
# Or for GUI applications, they are installed via flatpak. ./install-linux.sh
if [ "$OS_RELEASE" = "fedora" ]; then elif [[ "$OSTYPE" == "darwin"* ]]; then
echo_header "==[host] Detected Fedora" echo_header "== Detected macos"
rpm-ostree install --idempotent --apply-live --allow-inactive -y \ ./install-macos.sh
git git-lfs zsh curl htop wget else
elif [ "$OS_RELEASE" = "ubuntu" ]; then echo "Error: ${OSTYPE} is not supported!"
echo_header "==[host] Detected Ubuntu" exit 1
sudo apt-get update
sudo apt-get install -y \
git git-lfs zsh curl htop wget
fi fi
if [ "$GUI" = "YES" ]; then echo_header "== Installing Nix"
if [ "$OS_RELEASE" = "fedora" ]; then if ! command -v nix; then
echo_header "==[host:fedora] Installing GUI applications"
rpm-ostree install --idempotent --apply-live --allow-inactive -y \
kitty \
gphoto2 v4l2loopback ffmpeg \
ddcutil
echo_header "==[host:fedora] Installing docker"
cat <<EOF | sudo tee /etc/yum.repos.d/docker.repo >/dev/null
[docker-ce-stable]
name=Docker CE Stable - \$basearch
baseurl=https://download.docker.com/linux/fedora/\$releasever/\$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://download.docker.com/linux/fedora/gpg
EOF
rpm-ostree install --idempotent --apply-live --allow-inactive -y \
docker-ce docker-ce-cli \
containerd.io \
docker-buildx-plugin \
docker-compose-plugin
sudo usermod -aG docker $USER
echo "== Docker installed, restart will be needed to take effect."
elif [ "$OS_RELEASE" = "ubuntu" ]; then
echo_header "==[host:ubuntu] Installing GUI applications"
sudo apt-get update
sudo apt-get install -y \
kitty \
gphoto2 ffmpeg \
ddcutil
echo_header "==[host:ubuntu] Installing flatpak"
sudo apt-get install -y \
flatpak gnome-software-plugin-flatpak
echo_header "==[host:ubuntu] Installing docker"
sudo apt-get update
sudo apt-get install ca-certificates
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" |
sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo usermod -aG docker $USER
echo "== Docker installed, restart will be needed to take effect."
fi
echo_header "==[host] Installing flatpaks"
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install -y --user \
com.bitwarden.desktop \
md.obsidian.Obsidian \
org.mozilla.firefox \
org.mozilla.Thunderbird \
org.gnome.Builder \
com.vscodium.codium
echo_header "==[host] Installing fonts"
HOME_FONTS_DIR="${HOME_DIR}/.local/share/fonts"
mkdir -p ${HOME_FONTS_DIR}
rm -rf ${HOME_FONTS_DIR}/dotfiles-fonts
git clone --depth 1 git@github.com:mentos1386/dotfiles-fonts.git ${HOME_FONTS_DIR}/dotfiles-fonts
fc-cache
fi
echo_header "==[host] Installing Nix"
if ! nix --version; then
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
nix-channel --add https://nixos.org/channels/nixpkgs-unstable nix-channel --add https://nixos.org/channels/nixpkgs-unstable
@ -97,22 +25,22 @@ else
echo "Already installed, skipping" echo "Already installed, skipping"
fi fi
echo_header "==[host] Installing Home Manager" echo_header "== Installing Home Manager"
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --update nix-channel --update
NIXPKGS_ALLOW_UNFREE=1 ENVIRONMENT=$ENVIRONMENT nix-shell '<home-manager>' -A install NIXPKGS_ALLOW_UNFREE=1 ENVIRONMENT=$ENVIRONMENT nix-shell '<home-manager>' -A install
echo_header "==[host] Installing Home Manager packages" echo_header "== Installing Home Manager packages"
workspace_link nix/home.nix .config/home-manager/home.nix workspace_link nix/home.nix .config/home-manager/home.nix
workspace_link nix/core.nix .config/home-manager/core.nix workspace_link nix/core.nix .config/home-manager/core.nix
workspace_link nix/personal.nix .config/home-manager/personal.nix workspace_link nix/personal.nix .config/home-manager/personal.nix
workspace_link nix/work.nix .config/home-manager/work.nix workspace_link nix/work.nix .config/home-manager/work.nix
NIXPKGS_ALLOW_UNFREE=1 ENVIRONMENT=$ENVIRONMENT home-manager switch NIXPKGS_ALLOW_UNFREE=1 ENVIRONMENT=$ENVIRONMENT home-manager switch
echo_header "==[host] Use zsh as default shell" echo_header "== Use zsh as default shell"
sudo chsh $USER --shell=/bin/zsh sudo chsh $USER --shell=/bin/zsh
echo_header "==[host] Plug for neovim" echo_header "== Plug for neovim"
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \ sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
nvim --headless +PlugInstall +qa || true nvim --headless +PlugInstall +qa || true
@ -120,6 +48,6 @@ nvim --headless +PlugUpdate +qa || true
nvim --headless +PlugUpgrade +qa || true nvim --headless +PlugUpgrade +qa || true
if command -v code; then if command -v code; then
echo_header "==[host] Installing vscode extensions" echo_header "== Installing vscode extensions"
./vscode.sh --install ./vscode.sh --install
fi fi

View file

@ -1,6 +1,7 @@
#!/bin/env bash #!/bin/env bash
source common.sh source common.sh
echo_header "== DotFiles with GUI: $GUI and ENV: $ENVIRONMENT"
echo_header "==[host] Installing Home Manager packages" echo_header "==[host] Installing Home Manager packages"
workspace_link nix/home.nix .config/home-manager/home.nix workspace_link nix/home.nix .config/home-manager/home.nix