Skip to content

Commit

Permalink
Merge pull request #50 from kplachkov/add-fedora-silverblue
Browse files Browse the repository at this point in the history
Add Fedora Silverblue
  • Loading branch information
kplachkov authored Jan 30, 2025
2 parents 9cb8196 + fa288b5 commit 0d20deb
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 92 deletions.
12 changes: 6 additions & 6 deletions .bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# If not running interactively, then return.
case $- in
*i*) ;;
*) return ;;
esac

function _have() {
out=$(command -v "$@") || return $?
if [ $# -ne "$(printf "%s" "$out" | grep -c "^")" ]; then
Expand All @@ -18,6 +12,12 @@ function _have() {
fi
}

# If not running interactively, then return.
case $- in
*i*) ;;
*) return ;;
esac

if [ -d ~/.bashrc.d ]; then
for rc in ~/.bashrc.d/*; do
if [ -f "$rc" ]; then
Expand Down
5 changes: 0 additions & 5 deletions .bashrc.d/aliases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ alias -- -="cd -"
alias serve="python3 -m http.server"
alias edit='$EDITOR'

# Network.
alias edithosts='$EDITOR /etc/hosts'
alias lshosts="cat /etc/hosts"
alias lsnet="sudo netstat -tupln"

# Report.
alias ll='ls -alhF'
alias la='ls -A'
Expand Down
1 change: 0 additions & 1 deletion .bashrc.d/completions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Enable programmable completion features.
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
# shellcheck disable=SC1091
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
# shellcheck disable=SC1091
Expand Down
4 changes: 0 additions & 4 deletions .bashrc.d/less.sh

This file was deleted.

14 changes: 4 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ name: CI

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]

env:
DOTFILES_PATH: ${{ github.workspace }}
branches: [master]

jobs:
test:
Expand All @@ -16,18 +13,15 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]

os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v3

- name: "Test installation"
run: make auto-install
- run: make auto-install

lint:
name: "Lint"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

Expand Down
111 changes: 111 additions & 0 deletions .local/bin/tinyfetch
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/usr/bin/env bash

function log_fatal {
echo "$1" >&2
exit 1
}

function log_error {
echo "$1" >&2
}

function to_lower() {
if [ -t 0 ]; then
return 2
fi

cat | tr "[:upper:]" "[:lower:]"
}

function trim() {
if [ -t 0 ]; then
return 2
fi

input=$(cat) || return $?

# Remove leading whitespace characters.
input="${input#"${input%%[![:space:]]*}"}"

# Remove trailing whitespace characters.
input="${input%"${input##*[![:space:]]}"}"

printf '%s' "$input"
}

KERNEL=$(uname -s | to_lower)

function get_linux_distribution() {
source /etc/os-release

if [[ -z $ID ]]; then
log_error "Unknown OS."
return 3
fi

if [[ $ID == "ubuntu" && -z $DISPLAY && $TERM_PROGRAM == "vscode" ]]; then
echo "github-codespaces"
return
fi

if [[ $ID == "ubuntu" && -z $DISPLAY && -n $CI ]]; then
echo "github-ubuntu"
return
fi

if [[ -n $VARIANT_ID ]]; then
echo "$ID-$VARIANT_ID" | to_lower
return
fi

echo "$ID" | to_lower
}

function get_os() {
case $KERNEL in
linux)
get_linux_distribution || return $?
;;
darwin)
sw_vers -productName | to_lower
;;
*)
log_error "Unknown kernel ($KERNEL)."
return 2
;;
esac
}

function main() {
while getopts "ok" opt; do
case "$opt" in
o) os_opt=1 ;;
k) kernel_opt=1 ;;
?) exit 1 ;;
esac
done

if [[ -n $os_opt ]]; then
os=$(get_os || exit 1)
out="$os"
fi

if [[ -n $kernel_opt ]]; then
[[ -n $out ]] && out="-$out"
out="$KERNEL$out"
fi

if [[ -z $out ]]; then
os=$(get_os 2>/dev/null)

if [[ -z $os ]]; then
out="$KERNEL"
else
out="$KERNEL-$os"
fi
fi

echo "$out"
}

main "$@"
4 changes: 0 additions & 4 deletions .profile.d/exports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ if _have bat; then
export MANROFFOPT="-c"
fi

if [ -d "$HOME/bin" ]; then
PATH="$HOME/bin:$PATH"
fi

if [ -d "$HOME/.local/bin" ]; then
PATH="$HOME/.local/bin:$PATH"
fi
Expand Down
63 changes: 42 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,27 @@ help: ## Display this help.
auto-install: ## Run automated installation.
@./install.sh

OS_ID = $(shell grep -oP '^ID="?\K[a-zA-Z0-9_ ]+' /etc/os-release 2>/dev/null || uname | tr "[:upper:]" "[:lower:]")
KERNEL = $(shell uname -s | tr "[:upper:]" "[:lower:]")
OS = $(shell .local/bin/tinyfetch -o)
KERNEL = $(shell .local/bin/tinyfetch -k)

define git_install
git -C $3 fetch || git -c advice.detachedHead=false clone --branch $2 --depth 1 $1 $3
git -C $3 -c advice.detachedHead=false checkout $2
endef

ifeq ($(OS_ID),darwin)
ifeq ($(KERNEL),darwin)
brew = eval "$$(/opt/homebrew/bin/brew shellenv)" && brew
else
else ifeq ($(KERNEL),linux)
brew = eval "$$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" && brew
else
$(error Unsupported kernel ($(KERNEL)).)
endif

##@ Operating systems

fedora-workstation: configuration gnome dnf-packages tpm ## Install Fedora Workstation setup.

ubuntu-desktop: configuration gnome apt-packages tpm ## Install Ubuntu Desktop setup.
sudo ubuntu-drivers install

POWERLINE_REPOSITORY = https://github.com/powerline/powerline
POWERLINE_RELEASE = 2.8.4
POWERLINE_DIR = ~/.powerline
fedora-silverblue: configuration gnome rpm-ostree-packages flatpaks tpm ## Install Fedora Silverblue setup.

macos: configuration homebrew homebrew-packages tpm ## Install macOS setup.
$(call git_install,$(POWERLINE_REPOSITORY),$(POWERLINE_RELEASE),$(POWERLINE_DIR))
fedora-workstation: configuration gnome dnf-packages tpm ## Install Fedora Workstation setup.

github-codespaces: configuration apt-packages tpm homebrew ## Install GitHub Codespaces setup.
$(brew) install \
Expand All @@ -44,6 +38,16 @@ github-codespaces: configuration apt-packages tpm homebrew ## Install GitHub Cod
cp -R ~/.profile.d/* ~/.bashrc.d/
rm ~/.npmrc

POWERLINE_REPOSITORY = https://github.com/powerline/powerline
POWERLINE_RELEASE = 2.8.4
POWERLINE_DIR = ~/.powerline

macos: configuration homebrew homebrew-packages tpm ## Install macOS setup.
$(call git_install,$(POWERLINE_REPOSITORY),$(POWERLINE_RELEASE),$(POWERLINE_DIR))

ubuntu: configuration gnome apt-packages tpm ## Install Ubuntu setup.
sudo ubuntu-drivers install

##@ Desktop environments

gnome: ## Apply GNOME settings.
Expand Down Expand Up @@ -107,6 +111,17 @@ gnome: ## Apply GNOME settings.

##@ Software

rpm-ostree-packages: ## Install RPM-OSTree packages.
sudo rpm-ostree install \
alacritty \
bat \
libavcodec-freeworld \
openssl \
powerline \
powerline-fonts \
tmux \
tmux-powerline

dnf-packages: ## Install DNF packages.
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc && \
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo' && \
Expand Down Expand Up @@ -160,6 +175,11 @@ apt-packages: ## Install APT packages.
mkdir -p ~/.local/bin
ln -fs /usr/bin/batcat ~/.local/bin/bat

flatpaks:
flatpak install flathub \
org.gnome.Boxes \
com.mattjakeman.ExtensionManager

homebrew-packages: ## Install Homebrew packages.
$(brew) install \
go \
Expand All @@ -174,7 +194,7 @@ homebrew-packages: ## Install Homebrew packages.
hugo

homebrew: ## Install Homebrew.
bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
NONINTERACTIVE=1 bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
$(brew) analytics off

TPM_REPOSITORY = https://github.com/tmux-plugins/tpm
Expand All @@ -193,6 +213,7 @@ define EXPORTS_DF_SH_TEMPLATE

export POWERLINE_BASH_CONFIG='%s'
export POWERLINE_TMUX_CONFIG='%s'

endef

export EXPORTS_DF_SH_TEMPLATE
Expand All @@ -209,29 +230,29 @@ configuration: ## Apply configurations of packages and dotfiles.
cp .config/alacritty/base.toml .config/alacritty/theme.toml ~/.config/alacritty/
cp .config/alacritty/alacritty-$(KERNEL).toml ~/.config/alacritty/alacritty.toml

ifeq ($(OS_ID),fedora)
ifeq ($(OS),$(filter $(OS),fedora-silverblue fedora-workstation))
printf "$$EXPORTS_DF_SH_TEMPLATE" \
'/usr/share/powerline/bash/powerline.sh' \
'/usr/share/tmux/powerline.conf' \
> $(EXPORTS_DF_SH_PATH)
else ifeq ($(OS_ID),ubuntu)
else ifeq ($(OS),$(filter $(OS),github-codespaces github-ubuntu ubuntu))
printf "$$EXPORTS_DF_SH_TEMPLATE" \
'/usr/share/powerline/bindings/bash/powerline.sh' \
'/usr/share/powerline/bindings/tmux/powerline.conf' \
> $(EXPORTS_DF_SH_PATH)
else ifeq ($(OS_ID),darwin)
else ifeq ($(OS),macos)
printf "$$EXPORTS_DF_SH_TEMPLATE" \
'$(POWERLINE_DIR)/powerline/bindings/bash/powerline.sh' \
'$(POWERLINE_DIR)/powerline/bindings/tmux/powerline.conf' \
> $(EXPORTS_DF_SH_PATH)
else
$(warning Unsupported OS/kernel ($(OS_ID)). Powerline may not work.)
$(warning Unsupported OS ($(OS)). Powerline may not work.)
endif

gpg-key: ## Generate GPG key.
@gpg --full-generate-key

SSH_COMMENT = $(shell echo "$(USER) - $(OS_ID)")
SSH_COMMENT = $(shell echo "$(USER) - $(OS)")

ssh-keys: ## Generate SSH keys.
ssh-keygen -q -t rsa -b 4096 -C "$(SSH_COMMENT)" -f ~/.ssh/id_rsa
Expand All @@ -247,4 +268,4 @@ fmt: ## Format code.

lint: ## Lint code.
@shfmt -d -s .
@shellcheck $$(shfmt -f .)
@shellcheck -x $$(shfmt -f .)
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ make auto-install
```

Supported operating systems:
- Fedora Silverblue
- Fedora Workstation
- Ubuntu Desktop
- macOS
- GitHub Codespaces
- macOS
- Ubuntu

High level representation of the automated installation:
1. The automation determines the OS.
Expand Down
Loading

0 comments on commit 0d20deb

Please sign in to comment.