From 7b1c54bd85602d41904a6a36962c3412517559cb Mon Sep 17 00:00:00 2001 From: Liassica <115422798+Liassica@users.noreply.github.com> Date: Sun, 18 Aug 2024 15:42:26 -0500 Subject: [PATCH] feat: add alternative priv escalation https://github.com/thias/glim/pull/123 --- README.md | 2 +- nix/package/default.nix | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5cc31bb..7d4cf21 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ I've Nixified the upstream glim script, so it should work out of the box on syst Follow the upstream instructions for setting up your USB device. -Then, install glim to your USB by running `nix run github:Liassica/glim-flake`. You can override the theme by adding this repo as a flake input and overriding the 'theme' input. +Then, install glim to your USB by running `nix run github:Liassica/glim-flake`. You can override the theme or by adding this repo as a flake input and overriding the 'theme' input. E.g, to use the Breeze GRUB theme: diff --git a/nix/package/default.nix b/nix/package/default.nix index 3056ce0..67b02d8 100644 --- a/nix/package/default.nix +++ b/nix/package/default.nix @@ -11,6 +11,8 @@ let cfg = ../../grub2; in writeShellScriptBin "glim" '' + shopt -s expand_aliases + export PATH=${ lib.makeBinPath [ util-linux @@ -18,7 +20,7 @@ writeShellScriptBin "glim" '' grub2_efi rsync ] - }:$PATH + }:''$PATH # Check that we are *NOT* running as root if [[ `id -u` -eq 0 ]]; then @@ -26,6 +28,17 @@ writeShellScriptBin "glim" '' exit 1 fi + # Use alternative if sudo is not found + if [[ ! `which sudo &>/dev/null` ]]; then + if which doas &>/dev/null; then + alias sudo=doas + else + sudo () { + su -c "$*" + } + fi + fi + # Find GLIM device (use the first if multiple found, you've asked for trouble!) USBDEV1=`blkid -L GLIM | head -n 1`