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(just): combine several just commands into toggles or choices #181

Merged
merged 25 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
dab6274
chore: merge install/remove-distrobox-git
HikariKnight Jan 1, 2024
0d3f825
chore: merge enable/disable-updates
HikariKnight Jan 1, 2024
df095c1
chore: correct wording in description of distrobox-git
HikariKnight Jan 2, 2024
8b1067f
chore(just): merge ublue/stock-gamepads and enable/disable-broadcom-wl
HikariKnight Jan 2, 2024
b4afea2
chore(just): combine and merge all the nix recipes
HikariKnight Jan 2, 2024
0f46c73
chore(just): remove empty lines that were used for readability while …
HikariKnight Jan 2, 2024
b093094
chore(just): remove leftover spaces from before reorg
HikariKnight Jan 2, 2024
d15fd0a
chore(just): improve description wording for setup-distrobox-git and …
HikariKnight Jan 2, 2024
3dc413f
chore(just): format the message for configure-gamepads to look better
HikariKnight Jan 2, 2024
2f20dfc
chore(just): change gamepad description to be more clear
HikariKnight Jan 2, 2024
8269fd8
chore(just): merge nvidia recipes into configure-nvidia
HikariKnight Jan 3, 2024
8b3eb56
chore(just): change fixscreenshare to fix-screenshare to conform with…
HikariKnight Jan 3, 2024
d3e6398
chore(just): add some bold text for title or install state
HikariKnight Jan 4, 2024
12d8421
feat(just): add quick options for use in yafti
HikariKnight Jan 7, 2024
a1ca04a
chore(just): fix formating for just
HikariKnight Jan 7, 2024
430c840
chore(just): add missing quick options for setup-nix
HikariKnight Jan 7, 2024
c6cb6e6
chore(just): add aliases for recipes
HikariKnight Jan 7, 2024
8868c01
chore(just): add empty line between alias and recipe description
HikariKnight Jan 7, 2024
762c3ff
chore(just): added missing empty line for upgrade alias
HikariKnight Jan 7, 2024
23cca16
chore: Always use #!/usr/bin/bash
HikariKnight Jan 8, 2024
885361f
chore(just): fix conditions to be lowercase for enable/disable and in…
HikariKnight Jan 8, 2024
dee99ef
chore(just): standardize choice recipe ARG as ACTION
HikariKnight Jan 10, 2024
195893f
feat(just): add toggle-nvk, addresses #182
HikariKnight Jan 11, 2024
d068b2d
chore(just): Add message about what to do after running enroll-secure…
HikariKnight Jan 11, 2024
a0bad96
Merge branch 'main' into HikariKnight-just-reorg
HikariKnight Jan 12, 2024
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
32 changes: 20 additions & 12 deletions build/ublue-os-just/00-default.just
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bios:

# Change the user's shell
chsh new_shell:
#!/usr/bin/env bash
#!/usr/bin/bash
set -euo pipefail
if [ "{{ shell }}" = "{{ new_shell }}" ] ; then
printf "Your shell is already set to %s.\n" "{{ new_shell }}"
Expand All @@ -24,7 +24,7 @@ chsh new_shell:

# Regenerate GRUB config, useful in dual-boot scenarios where a second operating system isn't listed
regenerate-grub:
#!/usr/bin/env bash
#!/usr/bin/bash
if [ -d /sys/firmware/efi ]; then
sudo grub2-mkconfig -o /etc/grub2-efi.cfg
else
Expand All @@ -39,18 +39,26 @@ changelogs:
enroll-secure-boot-key:
echo 'Enter password "ublue-os" if prompted after your user password.'
sudo mokutil --import /etc/pki/akmods/certs/akmods-ublue.der --timeout -1
echo 'When you reboot your computer, follow the instructions to start MOK util'
echo 'by pressing a key, then enroll the secure boot key and enter "ublue-os" as the password'

# Upgrade Distrobox to the latest git version
distrobox-git:
echo 'Installing latest git snapshot of Distrobox...'
curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/install | sh -s -- --next --prefix ~/.local

# Downgrades Distrobox to the Fedora version
remove-distrobox-git:
echo 'Uninstalling latest git snapshot of Distrobox...'
curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/uninstall | sh -s -- --prefix ~/.local
# Install or uninstall distrobox-git
setup-distrobox-git:
#!/usr/bin/bash
echo 'Which version of Distrobox do you want to use?'
OPTION=$(ugum choose "Latest distrobox-git snapshot" "uBlue provided version")
if [ "$OPTION" == "Latest distrobox-git snapshot" ]; then
echo 'Installing latest git snapshot of Distrobox...'
curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/install | sh -s -- --next --prefix ~/.local
elif [ "$OPTION" == "uBlue provided version" ]; then
echo 'Uninstalling latest git snapshot of Distrobox...'
curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/uninstall | sh -s -- --prefix ~/.local
else
echo 'Cancelling...'
exit 0
fi

# Removes homebrew from system
brew-remove:
remove-brew:
echo "Removing homebrew ..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
59 changes: 37 additions & 22 deletions build/ublue-os-just/10-update.just
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# vim: set ft=make :

alias upgrade := update

# Update system, flatpaks, and containers all at once
update VERB_LEVEL="full":
#!/usr/bin/env bash
#!/usr/bin/bash
if systemctl is-enabled ublue-update.timer | grep -q enabled;
then
echo "Starting the ublue-update service"
Expand Down Expand Up @@ -73,26 +75,39 @@ update-firmware:
fwupdmgr get-updates
fwupdmgr update

# Disable all auto-update timers
disable-updates:
#!/usr/bin/env bash
if systemctl is-enabled ublue-update.timer | grep -q enabled;
then
sudo systemctl disable ublue-update.timer
elif systemctl is-enabled flatpak-system-update.timer | grep -q enabled;
then
sudo systemctl disable --now flatpak-system-update.timer rpm-ostreed-automatic.timer
systemctl disable --now --user flatpak-user-update.timer
fi
alias auto-update := toggle-updates

# Enable all auto-update timers
enable-updates:
#!/usr/bin/env bash
if systemctl is-enabled ublue-update.timer | grep -q disabled;
then
sudo systemctl enable ublue-update.timer
elif systemctl is-enabled flatpak-system-update.timer | grep -q disabled;
then
sudo systemctl enable --now flatpak-system-update.timer rpm-ostreed-automatic.timer
systemctl enable --now --user flatpak-user-update.timer
# Turn automatic updates on or off
toggle-updates ACTION="prompt":
#!/usr/bin/bash
CURRENT_STATE="Disabled"
if systemctl is-enabled ublue-update.timer | grep -q enabled; then
CURRENT_STATE="Enabled"
fi
bold=$(tput bold)
normal=$(tput sgr0)
OPTION={{ ACTION }}
if [ "$OPTION" == "prompt" ]; then
echo "Automatic updates are currently: ${bold}${CURRENT_STATE}${normal}"
echo "Enable or Disable automatic updates?"
OPTION=$(ugum choose Enable Disable)
elif [ "$OPTION" == "help" ]; then
echo "Usage: ujust toggle-updates <option>"
echo " <option>: Specify the quick option - 'enable' or 'disable'"
echo " Use 'enable' to Enable automatic updates."
echo " Use 'disable' to Disable automatic updates."
exit 0
fi
if [ "${OPTION,,}" == "enable" ]; then
sudo systemctl enable ublue-update.timer
if systemctl is-enabled flatpak-system-update.timer | grep -q disabled; then
sudo systemctl enable --now flatpak-system-update.timer rpm-ostreed-automatic.timer
systemctl enable --now --user flatpak-user-update.timer
fi
elif [ "${OPTION,,}" == "disable" ]; then
sudo systemctl disable ublue-update.timer
if systemctl is-enabled flatpak-system-update.timer | grep -q enabled; then
sudo systemctl disable --now flatpak-system-update.timer rpm-ostreed-automatic.timer
systemctl disable --now --user flatpak-user-update.timer
fi
fi
2 changes: 1 addition & 1 deletion build/ublue-os-just/20-clean.just
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Clean up old containers and flatpaks
clean-system:
#!/usr/bin/env bash
#!/usr/bin/bash
podman system prune -a
flatpak uninstall --unused
rpm-ostree cleanup -bm
Expand Down
2 changes: 1 addition & 1 deletion build/ublue-os-just/30-distrobox.just
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ distrobox-arch:

# Create a Bazzite-Arch container
distrobox-bazzite:
#!/usr/bin/env bash
#!/usr/bin/bash
echo 'Creating Bazzite distrobox ...'
if command -v /usr/bin/mutter > /dev/null; then
distrobox-create --unshare-netns --nvidia --image ghcr.io/ublue-os/bazzite-arch-gnome --name bazzite-arch -Y
Expand Down
107 changes: 67 additions & 40 deletions build/ublue-os-just/40-nvidia.just
Original file line number Diff line number Diff line change
@@ -1,47 +1,74 @@
# vim: set ft=make :

# Set needed kernel arguments for Nvidia GPUs
nvidia-set-kargs:
#!/usr/bin/env bash
if command -v nvidia-smi; then
rpm-ostree kargs \
--append-if-missing=rd.driver.blacklist=nouveau \
--append-if-missing=modprobe.blacklist=nouveau \
--append-if-missing=nvidia-drm.modeset=1 \
--delete-if-present=nomodeset
else
echo 'You do not appear to be on a Nvidia image, please refer to the README for your uBlue-OS image.'
fi
alias nvidia := configure-nvidia

# Test CUDA support for Nvidia GPUs
nvidia-test-cuda:
#!/usr/bin/env bash
if lsmod | grep -wq "nvidia"; then
podman run \
--user 1000:1000 \
--security-opt=no-new-privileges \
--cap-drop=ALL \
--security-opt label=type:nvidia_container_t \
--device=nvidia.com/gpu=all \
docker.io/nvidia/samples:vectoradd-cuda11.2.1
else
echo 'The Nvidia kernel module is not loaded. You may be using secure boot without the needed signing key, lacking the needed kargs, or may not be on a Nvidia image. See "just enroll-secure-boot-key" and "just nvidia-set-kargs".'
# Configure the Nvidia driver
configure-nvidia ACTION="prompt":
#!/usr/bin/bash
bold=$(tput bold)
normal=$(tput sgr0)
OPTION={{ ACTION }}
if [ "$OPTION" == "prompt" ]; then
echo "${bold}Configuring Nvidia drivers${normal}"
echo 'What would you like to do?'
OPTION=$(ugum choose "Set needed kernel arguments" "Test CUDA support" "Enable Nvidia VAAPI in Firefox Flatpak")
elif [ "$OPTION" == "help" ]; then
echo "Usage: ujust configure-nvidia <option>"
echo " <option>: Specify the quick option - 'kargs', 'test-cuda' or 'firefox-vaapi'"
echo " Use 'kargs' to Set needed kernel arguments"
echo " Use 'test-cuda' to Test CUDA support"
echo " Use 'firefox-vaapi' to Enable Nvidia VAAPI in Firefox Flatpak."
exit 0
fi
if [ "$OPTION" == "Set needed kernel arguments" ] || [ "${OPTION,,}" == "kargs" ]; then
if command -v nvidia-smi; then
rpm-ostree kargs \
--append-if-missing=rd.driver.blacklist=nouveau \
--append-if-missing=modprobe.blacklist=nouveau \
--append-if-missing=nvidia-drm.modeset=1 \
--delete-if-present=nomodeset
else
echo 'You do not appear to be on a Nvidia image, please refer to the README for your uBlue-OS image.'
fi
elif [ "$OPTION" == "Test CUDA support" ] || [ "${OPTION,,}" == "test-cuda" ]; then
if lsmod | grep -wq "nvidia"; then
podman run \
--user 1000:1000 \
--security-opt=no-new-privileges \
--cap-drop=ALL \
--security-opt label=type:nvidia_container_t \
--device=nvidia.com/gpu=all \
docker.io/nvidia/samples:vectoradd-cuda11.2.1
else
echo 'The Nvidia kernel module is not loaded. You may be using secure boot without the needed signing key, lacking the needed kargs, or may not be on a Nvidia image. See "just enroll-secure-boot-key" and "just nvidia-set-kargs".'
fi
elif [ "$OPTION" == "Enable Nvidia VAAPI in Firefox Flatpak" ] || [ "${OPTION,,}" == "firefox-vaapi" ]; then
if lsmod | grep -wq "nvidia"; then
flatpak override \
--user \
--filesystem=host-os \
--env=LIBVA_DRIVER_NAME=nvidia \
--env=LIBVA_DRIVERS_PATH=/run/host/usr/lib64/dri \
--env=LIBVA_MESSAGING_LEVEL=1 \
--env=MOZ_DISABLE_RDD_SANDBOX=1 \
--env=NVD_BACKEND=direct \
--env=MOZ_ENABLE_WAYLAND=1 \
org.mozilla.firefox
else
echo 'The Nvidia kernel module is not loaded. You may be using secure boot without the needed signing key, lacking the needed kargs, or may not be on a Nvidia image. See "just enroll-secure-boot-key" and "just nvidia-set-kargs".'
fi
fi

# Enable VAAPI in Firefox Flatpak for Nvidia GPUs
nvidia-setup-firefox-vaapi:
#!/usr/bin/env bash
if lsmod | grep -wq "nvidia"; then
flatpak override \
--user \
--filesystem=host-os \
--env=LIBVA_DRIVER_NAME=nvidia \
--env=LIBVA_DRIVERS_PATH=/run/host/usr/lib64/dri \
--env=LIBVA_MESSAGING_LEVEL=1 \
--env=MOZ_DISABLE_RDD_SANDBOX=1 \
--env=NVD_BACKEND=direct \
--env=MOZ_ENABLE_WAYLAND=1 \
org.mozilla.firefox
# Switch between Nvidia image and NVK
toggle-nvk:
#!/usr/bin/bash
CURRENT_IMAGE=$(rpm-ostree status -b --json | jq -r '.deployments[0]."container-image-reference"' | sed -E 's/^.+\/(.+:.+)$/\1/')
CURRENT_URI=$(rpm-ostree status -b --json | jq -r '.deployments[0]."container-image-reference"' | sed -E 's/^(.+\/).+:.+$/\1/')
NEW_IMAGE=$CURRENT_IMAGE
if [[ "$CURRENT_IMAGE" =~ "nvidia" ]]; then
NEW_IMAGE=${CURRENT_IMAGE/-nvidia/}
else
echo 'The Nvidia kernel module is not loaded. You may be using secure boot without the needed signing key, lacking the needed kargs, or may not be on a Nvidia image. See "just enroll-secure-boot-key" and "just nvidia-set-kargs".'
NEW_IMAGE=${CURRENT_IMAGE/:/-nvidia:}
fi
echo "Rebasing to ${NEW_IMAGE}"
rpm-ostree rebase ${CURRENT_URI}${NEW_IMAGE}
84 changes: 60 additions & 24 deletions build/ublue-os-just/50-akmods.just
Original file line number Diff line number Diff line change
@@ -1,29 +1,65 @@
# vim: set ft=make :

# Use stock gamepad drivers
use-stock-gamepads:
#!/usr/bin/env bash
sudo bash -c '> /etc/modprobe.d/xone.conf'
sudo bash -c '> /etc/modprobe.d/xpadneo.conf'
sudo bash -c '> /etc/modprobe.d/xpad-noone-blacklist.conf'
sudo bash -c '> /etc/modules-load.d/xpad-noone.conf'
alias gamepads := configure-gamepads

# Use uBlue gamepad drivers (Default)
use-ublue-gamepads:
#!/usr/bin/env bash
sudo rm -f /etc/modprobe.d/xone.conf
sudo rm -f /etc/modprobe.d/xpadneo.conf
sudo rm -f /etc/modprobe.d/xpad-noone-blacklist.conf
sudo rm -f /etc/modules-load.d/xpad-noone.conf
# Configure gamepad drivers
configure-gamepads ACTION="prompt":
#!/usr/bin/bash
bold=$(tput bold)
normal=$(tput sgr0)
OPTION={{ ACTION }}
if [ "$OPTION" == "prompt" ]; then
echo "${bold}Configuring gamepad drivers${normal}"
echo 'Which drivers do you want to use?'
echo 'Note: Enabling xone and xpadneo can break some 3rd party controllers'
OPTION=$(ugum choose "Default Fedora drivers" "Enable xone and xpadneo")
elif [ "$OPTION" == "help" ]; then
echo "Usage: ujust configure-gamepads <option>"
echo " <option>: Specify the quick option - 'stock' or 'ublue'"
echo " Use 'stock' to select Default Fedora Drivers"
echo " Use 'ublue' to select Enable xone and xpadneo"
exit 0
fi
if [ "$OPTION" == "Enable xone and xpadneo" ] || [ "$OPTION" == "ublue" ]; then
sudo rm -f /etc/modprobe.d/xone.conf
sudo rm -f /etc/modprobe.d/xpadneo.conf
sudo rm -f /etc/modprobe.d/xpad-noone-blacklist.conf
sudo rm -f /etc/modules-load.d/xpad-noone.conf
echo "${bold}Enabled${normal} xone and xpadneo, please reboot for changes to take effect"
elif [ "$OPTION" == "Default Fedora drivers" ] || [ "$OPTION" == "stock" ]; then
sudo bash -c '> /etc/modprobe.d/xone.conf'
sudo bash -c '> /etc/modprobe.d/xpadneo.conf'
sudo bash -c '> /etc/modprobe.d/xpad-noone-blacklist.conf'
sudo bash -c '> /etc/modules-load.d/xpad-noone.conf'
echo "${bold}Disabled${normal} xone and xpadneo, please reboot for changes to take effect"
fi

# Disable Broadcom WL driver (Default - WL breaks numerous other Wi-Fi adapters)
disable-broadcom-wl:
#!/usr/bin/env bash
sudo bash -c '> /etc/modules-load.d/broadcom-wl-blacklist.conf'
sudo bash -c 'echo "blacklist wl" > /etc/modules-load.d/default-disable-broadcom-wl.conf'
alias broadcom-wl := configure-broadcom-wl

# Use Broadcom WL driver
use-broadcom-wl:
#!/usr/bin/env bash
sudo rm -f /etc/modprobe.d/broadcom-wl-blacklist.conf
sudo rm -f /etc/modprobe.d/default-disable-broadcom-wl.conf
# Configure Broadcom WL driver (Enabling WL breaks numerous other Wi-Fi adapters)
configure-broadcom-wl ACTION="prompt":
#!/usr/bin/bash
bold=$(tput bold)
normal=$(tput sgr0)
OPTION={{ ACTION }}
if [ "$OPTION" == "prompt" ]; then
echo "${bold}Configuring Broadcom Wi-Fi${normal}"
echo 'Enabling Broadcom WL driver will break numerous other Wi-Fi adapters.'
echo 'Enable or Disable Broadcom Wl?'
OPTION=$(ugum choose Enable Disable)
elif [ "$OPTION" == "help" ]; then
echo "Usage: ujust configure-broadcom-wl <option>"
echo " <option>: Specify the quick option - 'enable' or 'disable'"
echo " Use 'enable' to select Enable"
echo " Use 'disable' to select Disable"
exit 0
fi
if [ "${OPTION,,}" == "enable" ]; then
sudo rm -f /etc/modprobe.d/broadcom-wl-blacklist.conf
sudo rm -f /etc/modprobe.d/default-disable-broadcom-wl.conf
echo "${bold}Enabled${normal} Broadcom Wireless, please reboot for changes to take effect"
elif [ "${OPTION,,}" == "disable" ]; then
sudo bash -c '> /etc/modules-load.d/broadcom-wl-blacklist.conf'
sudo bash -c 'echo "blacklist wl" > /etc/modules-load.d/default-disable-broadcom-wl.conf'
echo "${bold}Disabled${normal} Broadcom Wireless, please reboot for changes to take effect"
fi
2 changes: 1 addition & 1 deletion build/ublue-os-just/60-custom.just
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# vim: set ft=make :

# Enable xwaylandvideobridge
fixscreenshare:
fix-screenshare:
cp /usr/share/applications/org.kde.xwaylandvideobridge.desktop $HOME/.config/autostart/
Loading