Skip to content

Commit

Permalink
Support NixOS (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmadisetti committed Apr 10, 2022
1 parent 6b2a93c commit 6eeaec5
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions grub2_theme_preview/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def parse_command_line(argv):


def _grub2_directory(platform):
return '/usr/lib/grub/%s' % platform
return '{}/{}'.format(os.environ.get('G2TP_GRUB_LIB', '/usr/lib/grub'), platform)


def _grub2_platform():
Expand All @@ -361,12 +361,17 @@ def _grub2_ovmf_tuple():
2. a display hint for humans where the file is located, roughly
3. a list of package names to try install, potentially
"""
candidates = [
'/usr/share/edk2-ovmf/OVMF_CODE.fd', # Gentoo and its derivatives
'/usr/share/edk2-ovmf/x64/OVMF_CODE.fd', # Arch Linux and its derivatives
'/usr/share/OVMF/OVMF_CODE.fd', # Debian and its derivatives
'/usr/share/edk2/ovmf/OVMF_CODE.fd', # Fedora (and its derivatives?)
]
omvf_image = os.environ.get('G2TP_OVMF_IMAGE')
if omvf_image is not None: # Support non-standard locations e.g. NixOS
candidates = [omvf_image]
else:
candidates = [
'/usr/share/edk2-ovmf/OVMF_CODE.fd', # Gentoo and its derivatives
'/usr/share/edk2-ovmf/x64/OVMF_CODE.fd', # Arch Linux and its derivatives
'/usr/share/OVMF/OVMF_CODE.fd', # Debian and its derivatives
'/usr/share/edk2/ovmf/OVMF_CODE.fd', # Fedora (and its derivatives?)
]

for candidate in candidates:
if os.path.exists(candidate):
return candidate, None, []
Expand Down

0 comments on commit 6eeaec5

Please sign in to comment.