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: homebrew on image #1293

Merged
merged 21 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
11 changes: 11 additions & 0 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ jobs:

- name: Check just syntax
uses: ublue-os/just-action@v1

- name: Update podman
run: |
# from https://askubuntu.com/questions/1414446/whats-the-recommended-way-of-installing-podman-4-in-ubuntu-22-04
ubuntu_version='22.04'
key_url="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_${ubuntu_version}/Release.key"
sources_url="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_${ubuntu_version}"
echo "deb $sources_url/ /" | sudo tee /etc/apt/sources.list.d/devel-kubic-libcontainers-unstable.list
curl -fsSL $key_url | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/devel_kubic_libcontainers_unstable.gpg > /dev/null
sudo apt update
sudo apt install -y podman

- name: Generate tags
id: generate-tags
Expand Down
8 changes: 5 additions & 3 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ ARG BASE_IMAGE="ghcr.io/ublue-os/${SOURCE_IMAGE}"
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-40}"
ARG TARGET_BASE="${TARGET_BASE:-bluefin}"

# KMODs
# FROM's for copying
ARG KMOD_SOURCE_COMMON="ghcr.io/ublue-os/akmods:${AKMODS_FLAVOR}-${FEDORA_MAJOR_VERSION}"
FROM ${KMOD_SOURCE_COMMON} as akmods
FROM ghcr.io/ublue-os/bluefin-cli as bluefin-cli

## bluefin image section
FROM ${BASE_IMAGE}:${FEDORA_MAJOR_VERSION} AS base
Expand All @@ -29,8 +30,9 @@ COPY packages.json /tmp/packages.json
# Copy ublue-update.toml to tmp first, to avoid being overwritten.
COPY /system_files/shared/usr/etc/ublue-update/ublue-update.toml /tmp/ublue-update.toml
# Copy Bluefin CLI packages
COPY --from=ghcr.io/ublue-os/bluefin-cli /usr/bin/atuin /usr/bin/atuin
COPY --from=ghcr.io/ublue-os/bluefin-cli /usr/share/bash-prexec /usr/share/bash-prexec
COPY --from=bluefin-cli /usr/bin/atuin /usr/bin/atuin
COPY --from=bluefin-cli /usr/share/bash-prexec /usr/share/bash-prexec
# COPY --from=bluefin-cli /home/homebrew /usr/share/homebrew
# COPY ublue kmods, add needed negativo17 repo and then immediately disable due to incompatibility with RPMFusion
COPY --from=akmods /rpms /tmp/akmods-rpms

Expand Down
6 changes: 4 additions & 2 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ just-check:
#!/usr/bin/bash
find "${project_root}" -type f -name "*.just" | while read -r file; do
echo "Checking syntax: $file"
just --unstable --fmt --check -f $file || { exit 1; }
just --unstable --fmt --check -f $file
done
just --unstable --fmt --check -f ${project_root}/Justfile || { exit 1; }
echo "Checking syntax: ${project_root}/Justfile"
just --unstable --fmt --check -f ${project_root}/Justfile

# Fix Just Syntax
[private]
Expand All @@ -33,6 +34,7 @@ just-fix:
echo "Checking syntax: $file"
just --unstable --fmt -f $file || { exit 1; }
done
echo "Checking syntax: ${project_root}/Justfile"
just --unstable --fmt -f ${project_root}/Justfile || { exit 1; }

# Build Image
Expand Down
20 changes: 20 additions & 0 deletions build_files/base/brew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/bash

set -xeou pipefail

# Convince the installer we are in CI
if [[ ! -f /.dockerenv ]]; then
touch /.dockerenv
fi

# Make these so script will work
mkdir -p /var/home
mkdir -p /var/roothome

# Install brew, Get portable Ruby
/usr/libexec/brew-install
/home/linuxbrew/.linuxbrew/bin/brew update

# Copy to image and own by UID 1000
cp -R /home/linuxbrew /usr/share/homebrew
chown -R 1000:1000 /usr/share/homebrew
1 change: 1 addition & 0 deletions build_files/base/build-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set -ouex pipefail
. /tmp/build/nvidia.sh
. /tmp/build/image-info.sh
. /tmp/build/fetch-install.sh
. /tmp/build/brew.sh
. /tmp/build/fetch-quadlets.sh
. /tmp/build/font-install.sh
. /tmp/build/systemd.sh
Expand Down
3 changes: 3 additions & 0 deletions build_files/base/systemd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ systemctl enable ublue-update.timer
systemctl enable ublue-system-setup.service
systemctl enable ublue-etc-merge.service
systemctl enable ublue-guest-user.service
systemctl enable var-home-linuxbrew.mount
systemctl enable brew-upgrade.timer
systemctl enable brew-update.timer
systemctl --global enable ublue-user-setup.service
systemctl --global enable podman-auto-update.timer
9 changes: 7 additions & 2 deletions just/bluefin-system.just
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ benchmark:
echo 'Running a 1 minute benchmark ...'
cd /tmp && stress-ng --matrix 0 -t 1m --times

# Configure Bluefin-CLI Terminal Experience
# Configure Bluefin-CLI Terminal Experience with Brew
bluefin-cli:
brew bundle --file /usr/share/ublue-os/homebrew/bluefin-cli.Brewfile

m2Giles marked this conversation as resolved.
Show resolved Hide resolved
# Configure Bluefin-CLI Terminal Experience
[private]
bluefin-cli-container:
@/usr/libexec/enable-bluefin-cli.sh

# Configure Terminal Experience
Expand Down Expand Up @@ -283,7 +288,7 @@ install-system-flatpaks:
FLATPAKS="aurora_flatpaks/flatpaks"
fi
FLATPAK_LIST="$(curl https://raw.githubusercontent.com/ublue-os/bluefin/main/${FLATPAKS} | tr '\n' ' ')"
flatpak --system -y install ${FLATPAK_LIST}
flatpak --system -y install --or-update ${FLATPAK_LIST}

# Configure grub bootmenu visibility
configure-grub:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
#!/usr/bin/fish
#shellcheck disable=all
alias fastfetch="/usr/bin/fastfetch --file /usr/share/ublue-os/aurora-logo.txt --logo-type file --logo-color-1 94 --logo-color-2 95 --logo-color-3 91 --logo-color-4 97 -c /usr/share/ublue-os/ublue-os.jsonc"
2 changes: 1 addition & 1 deletion system_files/kinoite/usr/share/ublue-os/motd/bluefin.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Let's trace the stars.
| ------- | ----------- |
| `ujust --choose` | Display available commands with search |
| `ujust toggle-user-motd` | Toggle this banner on/off |
| `ujust brew` | Install Homebrew (Strongly Recommended) |
| `ujust bluefin-cli` | Install Terminal Bling w/ Brew |
m2Giles marked this conversation as resolved.
Show resolved Hide resolved

%TIP%

Expand Down
25 changes: 25 additions & 0 deletions system_files/shared/usr/etc/profile.d/brew-bash-completion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh
# shellcheck shell=sh disable=SC1091,SC2039,SC2166
# Check for interactive bash and that we haven't already been sourced.
if [ "x${BASH_VERSION-}" != x -a "x${PS1-}" != x -a "x${BREW_BASH_COMPLETION-}" = x ]; then

# Check for recent enough version of bash.
if [ "${BASH_VERSINFO[0]}" -gt 4 ] ||
[ "${BASH_VERSINFO[0]}" -eq 4 -a "${BASH_VERSINFO[1]}" -ge 2 ]; then
if [ -w /home/linuxbrew/.linuxbrew ]; then
if ! test -L /home/linuxbrew/.linuxbrew/etc/bash_completion.d/brew; then
/home/linuxbrew/.linuxbrew/bin/brew completions link > /dev/null
fi
fi
if test -d /home/linuxbrew/.linuxbrew/etc/bash_completion.d; then
for rc in /home/linuxbrew/.linuxbrew/etc/bash_completion.d/*; do
if test -r "$rc"; then
. "$rc"
fi
done
unset rc
fi
fi
BREW_BASH_COMPLETION=1
export BREW_BASH_COMPLETION
fi
6 changes: 6 additions & 0 deletions system_files/shared/usr/etc/profile.d/brew-on-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

if systemctl --quiet is-active var-home-linuxbrew.mount; then
HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_NO_AUTO_UPDATE
fi
4 changes: 2 additions & 2 deletions system_files/shared/usr/etc/profile.d/brew.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
[[ -d /home/linuxbrew/.linuxbrew && $- == *i* ]] && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
#!/usr/bin/bash
[[ -d /home/linuxbrew/.linuxbrew && $- == *i* ]] && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
9 changes: 8 additions & 1 deletion system_files/shared/usr/etc/zsh/zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,16 @@ colors
# Sourcing
#####################

# Brew
# Brew
if [[ -o interactive ]] && [[ -d /home/linuxbrew/.linuxbrew ]]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
if type brew &>/dev/null; then
if [[ -w /home/linuxbrew/.linuxbrew ]]; then
if [[ ! -L "$(brew --prefix)/share/zsh/site-functions/_brew" ]]; then
brew completions link
fi
fi
fi
fi

# Starship
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
enable var-home-linuxbrew.mount
enable brew-update.timer
enable brew-upgrade.timer
12 changes: 12 additions & 0 deletions system_files/shared/usr/lib/systemd/system/brew-update.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Auto update brew for mutable brew installs
After=local-fs.target
ConditionPathIsMountPoint=!/var/home/linuxbrew
ConditionPathExists=/home/linuxbrew/.linuxbrew/bin/brew

[Service]
# Override the user if different UID/User
User=1000
Type=oneshot
ExecStart=/home/linuxbrew/.linuxbrew/bin/brew update
StandardOutput=journal
11 changes: 11 additions & 0 deletions system_files/shared/usr/lib/systemd/system/brew-update.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Timer for brew update for mutable brew
Wants=network-online.target

[Timer]
OnBootSec=20min
OnUnitInactiveSec=6h
Persistent=true

[Install]
WantedBy=timers.target
12 changes: 12 additions & 0 deletions system_files/shared/usr/lib/systemd/system/brew-upgrade.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Upgrade Brew packages
After=local-fs.target
ConditionPathExists=/home/linuxbrew/.linuxbrew/bin/brew

[Service]
# Override the user if different UID/User
User=1000
Type=oneshot
Environment=HOMEBREW_NO_AUTO_UPDATE=1
ExecStart=/home/linuxbrew/.linuxbrew/bin/brew upgrade
StandardOutput=journal
11 changes: 11 additions & 0 deletions system_files/shared/usr/lib/systemd/system/brew-upgrade.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Timer for brew upgrade for on image brew
Wants=network-online.target

[Timer]
OnBootSec=20min
OnUnitInactiveSec=6h
Persistent=true

[Install]
WantedBy=timers.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Cleanup Homebrew workdir
After=var.mount
Before=var-home-linuxbrew.mount
ConditionPathIsDirectory=%C/homebrew

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=-/usr/bin/rm -rf %C/homebrew/.*
ExecStart=-/usr/bin/rm -rf %C/homebrew/*
ExecStop=-/usr/bin/rm -rf %C/homebrew/.*
ExecStop=-/usr/bin/rm -rf %C/homebrew/*

[Install]
WantedBy=default.target multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=Homebrew overlay mount
Wants=cleanup-homebrew.service
After=cleanup-homebrew.service
After=var-mount.mount
ConditionPathIsDirectory=%S/homebrew
ConditionPathIsDirectory=%C/homebrew
ConditionPathExists=!/var/home/linuxbrew/.linuxbrew

[Mount]
Type=overlay
What=overlay
Options=lowerdir=/usr/share/homebrew,upperdir=%S/homebrew,workdir=%C/homebrew
Where=/var/home/linuxbrew

[Install]
WantedBy=local-fs.target
3 changes: 3 additions & 0 deletions system_files/shared/usr/lib/tmpfiles.d/homebrew.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
d /var/lib/homebrew 0755 1000 1000 - -
d /var/cache/homebrew 0755 1000 1000 - -
d /var/home/linuxbrew 0755 1000 1000 - -
22 changes: 21 additions & 1 deletion system_files/shared/usr/share/fish/vendor_conf.d/brew.fish
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
[ -d /home/linuxbrew/.linuxbrew ] && status --is-interactive && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
#!/usr/bin/fish
#shellcheck disable=all
if status --is-interactive
if [ -d /home/linuxbrew/.linuxbrew ]
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
if [ -w /home/linuxbrew/.linuxbrew ]
if [ ! -L (brew --prefix)/share/fish/vendor_completions.d/brew]
brew completions link > /dev/null
end
end
if test -d (brew --prefix)/share/fish/completions
set -p fish_complete_path (brew --prefix)/share/fish/completions
end
if test -d (brew --prefix)/share/fish/vendor_completions.d
set -p fish_complete_path (brew --prefix)/share/fish/vendor_completions.d
end
end
if systemctl --quiet is-active var-home-linuxbrew.mount
set -gx HOMEBREW_NO_AUTO_UPDATE 1
end
end
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/fish
#shellcheck disable=all

alias neofetch=fastfetch
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/fish
#shellcheck disable=all

function fish_greeting
if test -d "$HOME"
if test ! -e "$HOME"/.config/no-show-user-motd
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
brew "atuin"
brew "bat"
brew "direnv"
brew "eza"
brew "fd"
brew "gh"
brew "glab"
brew "rg"
brew "ugrep"
brew "yq"
brew "zoxide"
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
#!/usr/bin/fish
#shellcheck disable=all
alias fastfetch="/usr/bin/fastfetch --logo /usr/share/ublue-os/bluefin-logos/symbols/dolly -c /usr/share/ublue-os/ublue-os.jsonc"
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
| ------- | ----------- |
| `ujust --choose` | Display available commands with search |
| `ujust toggle-user-motd` | Toggle this banner on/off |
| `ujust brew` | Install Homebrew (Strongly Recommended) |
| `ujust bluefin-cli` | Install Terminal Bling w/ Brew |
m2Giles marked this conversation as resolved.
Show resolved Hide resolved

%TIP%

Expand Down
Loading