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

fix: Split justfiles into multiple numbered files to fix issue with default command on other releases. #118

Merged
merged 14 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from 13 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
20 changes: 20 additions & 0 deletions build/ublue-os-just/00-default.just
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# vim: set ft=make :

set allow-duplicate-recipes
set ignore-comments

_default:
@just --unstable --list --list-heading $'Available commands:\n' --list-prefix $' - '

# Boot into this device's BIOS/UEFI screen
bios:
systemctl reboot --firmware-setup

# Show the changelog
changelogs:
rpm-ostree db diff --changelogs

# Enroll Nvidia driver & KMOD signing key for secure boot - Enter password "ublue-os" if prompted
enroll-secure-boot-key:
sudo mokutil --import /etc/pki/akmods/certs/akmods-ublue.der
echo 'Enter password "ublue-os" if prompted'
7 changes: 7 additions & 0 deletions build/ublue-os-just/10-update.just
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# vim: set ft=make :

# Update system, flatpaks, and containers all at once
update:
rpm-ostree update
flatpak update -y
distrobox upgrade -a
12 changes: 12 additions & 0 deletions build/ublue-os-just/20-clean.just
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# vim: set ft=make :

# Clean up old containers and flatpaks
clean-system:
#!/usr/bin/env bash
podman system prune -a
flatpak uninstall --unused
rpm-ostree cleanup -bm
if [ -x "$(command -v nix-store)" ]; then
nix-store --gc
nix-store --optimise
fi
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
default:
@just --unstable --list

# Boot into this device's BIOS/UEFI screen
bios:
systemctl reboot --firmware-setup

# Clean up old containers and flatpaks
clean:
podman system prune -a
flatpak uninstall --unused
rpm-ostree cleanup -bm

# Show the changelog
changelogs:
rpm-ostree db diff --changelogs
# vim: set ft=make :

# Create an Arch container
distrobox-arch:
echo 'Creating Arch distrobox ...'
distrobox create --nvidia --image quay.io/toolbx-images/archlinux-toolbox:latest -n arch -Y

# Create a Bazzite container
# Create a Bazzite-Arch container
distrobox-bazzite:
#!/usr/bin/env bash
echo 'Creating Bazzite distrobox ...'
Expand All @@ -44,7 +29,7 @@ distrobox-debian:
# Create a Fedora container
distrobox-fedora:
echo 'Creating Fedora distrobox ...'
distrobox create --nvidia --image registry.fedoraproject.org/fedora-toolbox:38 -n fedora -Y
distrobox create --nvidia --image ghcr.io/ublue-os/fedora-distrobox:latest -n fedora -Y

# Create an openSUSE container
distrobox-opensuse:
Expand All @@ -56,17 +41,8 @@ distrobox-ubuntu:
echo 'Creating Ubuntu distrobox ...'
distrobox create --nvidia --image quay.io/toolbx-images/ubuntu-toolbox:22.04 -n ubuntu -Y

# Enroll secure boot key
enroll-secure-boot-key:
sudo mokutil --import /etc/pki/akmods/certs/akmods-ublue.der

# Update system, flatpaks, and containers all at once
update:
rpm-ostree update
flatpak update -y
distrobox upgrade -a

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

# Install obs-studio-portable from wimpysworld, which bundles an extensive collection of 3rd party plugins
install-obs-studio-portable:
echo 'Installing obs-studio-portable...' && \
distrobox create --nvidia --no-entry --image ghcr.io/ublue-os/obs-studio-portable -n obs-studio-portable -Y && \
distrobox-enter -n obs-studio-portable -- 'bash -c "distrobox-export --app obs"'
41 changes: 41 additions & 0 deletions build/ublue-os-just/40-nvidia.just
KyleGospo marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# vim: set ft=make :

# Set needed kernel arguments for Nvidia GPUs
nvidia-set-kargs:
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

# 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 \
docker.io/mirrorgooglecontainers/cuda-vector-add:v0.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

# 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
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
29 changes: 29 additions & 0 deletions build/ublue-os-just/50-akmods.just
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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'

# 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

# 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'

# 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
5 changes: 5 additions & 0 deletions build/ublue-os-just/60-custom.just
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# vim: set ft=make :

# Enable xwaylandvideobridge
fixscreenshare:
cp /usr/share/applications/org.kde.xwaylandvideobridge.desktop $HOME/.config/autostart/
2 changes: 1 addition & 1 deletion build/ublue-os-just/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

mkdir -p /tmp/ublue-os/rpmbuild/SOURCES

cp ${SCRIPT_DIR}/{custom,main,nvidia}.just /tmp/ublue-os/rpmbuild/SOURCES
cp ${SCRIPT_DIR}/*.just /tmp/ublue-os/rpmbuild/SOURCES
cp ${SCRIPT_DIR}/ublue-os-just.sh /tmp/ublue-os/rpmbuild/SOURCES

rpmbuild -ba \
Expand Down
Empty file removed build/ublue-os-just/custom.just
Empty file.
27 changes: 0 additions & 27 deletions build/ublue-os-just/nvidia.just

This file was deleted.

14 changes: 11 additions & 3 deletions build/ublue-os-just/ublue-os-just.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ alias just="just --unstable"

if [ ! -z "$HOME" ] && [ -d "$HOME" ] && [ ! -f "${HOME}/.justfile" ]; then
cat > "${HOME}/.justfile" << EOF
!include /usr/share/ublue-os/just/main.just
!include /usr/share/ublue-os/just/nvidia.just
!include /usr/share/ublue-os/just/custom.just
!include /usr/share/ublue-os/justfile
EOF
fi

if [ -f "${HOME}/.justfile" ]; then
if ! grep -Fxq '!include /usr/share/ublue-os/justfile' "${HOME}/.justfile"; then
# Remove any lines we may have added previously.
sed -i '/!include \/usr\/share\/ublue-os\/just\/.*.just/d' "${HOME}/.justfile"

# Point to the new main justfile, place it as the first line
sed -i '1s/^/!include \/usr\/share\/ublue-os\/justfile\n/' "${HOME}/.justfile"
fi
fi
33 changes: 24 additions & 9 deletions build/ublue-os-just/ublue-os-just.spec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Name: ublue-os-just
Packager: ublue-os
Vendor: ublue-os
Version: 0.2
Version: 0.3
Release: 1%{?dist}
Summary: ublue-os just integration
License: MIT
Expand All @@ -11,9 +11,13 @@ BuildArch: noarch
Supplements: just

Source0: ublue-os-just.sh
Source1: custom.just
Source2: main.just
Source3: nvidia.just
Source1: 00-default.just
Source2: 10-update.just
Source3: 20-clean.just
Source4: 30-distrobox.just
Source5: 40-nvidia.just
Source6: 50-akmods.just
Source7: 60-custom.just

%global sub_name %{lua:t=string.gsub(rpm.expand("%{NAME}"), "^ublue%-os%-", ""); print(t)}

Expand All @@ -26,18 +30,29 @@ Adds ublue-os just integration for easier setup
%build

mkdir -p -m0755 %{buildroot}%{_datadir}/%{VENDOR}/%{sub_name}
cp %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{buildroot}%{_datadir}/%{VENDOR}/%{sub_name}
install -Dm755 %{SOURCE0} %{buildroot}%{_sysconfdir}/profile.d/ublue-os-just.sh
install -Dm755 %{SOURCE0} %{buildroot}%{_datarootdir}/fish/vendor_conf.d/ublue-os-just.fish
cp %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} %{SOURCE5} %{SOURCE6} %{SOURCE7} %{buildroot}%{_datadir}/%{VENDOR}/%{sub_name}

# Create justfile which contains all .just files included in this package
for justfile in %{buildroot}%{_datadir}/%{VENDOR}/%{sub_name}/*.just; do
echo "!include %{_datadir}/%{VENDOR}/%{sub_name}/${justfile}" >> "%{buildroot}%{_datadir}/%{VENDOR}/justfile"
done

%files
%dir %attr(0755,root,root) %{_datadir}/%{VENDOR}/%{sub_name}
%attr(0644,root,root) %{_datadir}/%{VENDOR}/%{sub_name}/custom.just
%attr(0644,root,root) %{_datadir}/%{VENDOR}/%{sub_name}/main.just
%attr(0644,root,root) %{_datadir}/%{VENDOR}/%{sub_name}/nvidia.just
%attr(0755,root,root) %{_datadir}/%{VENDOR}/%{sub_name}/ublue-os-just.sh
%attr(0755,root,root) %{_sysconfdir}/profile.d/ublue-os-just.sh
%attr(0755,root,root) %{_datarootdir}/fish/vendor_conf.d/ublue-os-just.fish
%attr(0644,root,root) %{_datadir}/%{VENDOR}/%{sub_name}/*.just
%attr(0644,root,root) %{_datadir}/%{VENDOR}/justfile

%changelog
* Thu Sep 21 2023 Kyle Gospodnetich <[email protected]> - 0.3
- Modify just files to be numbered for ordered loading
- Move to using a single master justfile
- Clean up previous installs to point to new file
- Add support for fish shell

* Sat May 13 2023 Benjamin Sherman <[email protected]> - 0.2
- Refactor directory structure
- Rename justfile to main.just
Expand Down