Skip to content

Commit 57ba3f1

Browse files
committed
feat: add alternative priv escalation
thias#123
1 parent c34f93a commit 57ba3f1

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@ A flake for [glim](https://github.com/thias/glim) with a couple of customization
44

55
## Overview
66

7-
I've Nixified the upstream glim script, so it should work out of the box on systems with Nix. I've also added a few customizations like enabling Secure Boot support and switching the default theme out for [Catppuccin Frappe](https://github.com/catppuccin/grub).
7+
I've Nixified the upstream glim script, so it should work out of the box on systems with Nix. I've also added a few customizations like enabling Secure Boot support, switching the default theme out for [Catppuccin Frappe](https://github.com/catppuccin/grub), and using doas instead of sudo.
88

99
## Installation
1010

1111
Follow the upstream instructions for setting up your USB device.
1212

13-
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.
13+
Then, install glim to your USB by running `nix run github:Liassica/glim-flake`. You can override the theme or privilege escalation by adding this repo as a flake input and overriding the 'theme' and 'priv_esc' inputs.
1414

15-
E.g, to use the Breeze GRUB theme:
15+
E.g, to use the Breeze GRUB theme and sudo:
1616

1717
```nix
1818
{ pkgs, glim, ...}:
1919
{
2020
environment.systemPackages = [
2121
glim.packages.x86_64-linux.glim.override {
2222
theme = "${pkgs.kdePackages.breeze-grub}/grub/themes/breeze";
23+
priv_esc = pkgs.sudo;
2324
};
2425
];
2526
}

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
packages.${system} = {
1212
glim = pkgs.callPackage ./nix/package {
1313
theme = (pkgs.catppuccin-grub.override { flavor = "frappe"; }).outPath;
14+
priv_esc = pkgs.doas;
1415
};
1516
default = self.packages.${system}.glim;
1617
};

nix/package/default.nix

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
rsync,
77
writeShellScriptBin,
88
theme,
9+
priv_esc,
910
}:
1011
let
1112
cfg = ../../grub2;
@@ -17,12 +18,13 @@ writeShellScriptBin "glim" ''
1718
coreutils-full
1819
grub2_efi
1920
rsync
21+
priv_esc
2022
]
2123
}:$PATH
2224
2325
# Check that we are *NOT* running as root
2426
if [[ `id -u` -eq 0 ]]; then
25-
echo "ERROR: Don't run as root, use a user with full sudo access."
27+
echo "ERROR: Don't run as root, use a user with full ${priv_esc.pname} access."
2628
exit 1
2729
fi
2830
@@ -71,8 +73,8 @@ writeShellScriptBin "glim" ''
7173
7274
# Install GRUB2
7375
GRUB_TARGET="--target=x86_64-efi --efi-directory=''${USBMNT} --removable --modules='tpm' --disable-shim-lock"
74-
echo "Running grub-install ''${GRUB_TARGET} --boot-directory=''${USBMNT}/boot (with sudo)..."
75-
sudo grub-install ''${GRUB_TARGET} --boot-directory=''${USBMNT}/boot ''${USBDEV}
76+
echo "Running grub-install ''${GRUB_TARGET} --boot-directory=''${USBMNT}/boot (with ${priv_esc.pname})..."
77+
${lib.getExe priv_esc} grub-install ''${GRUB_TARGET} --boot-directory=''${USBMNT}/boot ''${USBDEV}
7678
if [[ $? -ne 0 ]]; then
7779
echo "ERROR: grub-install returned with an error exit status."
7880
exit 1

0 commit comments

Comments
 (0)