From 46e3e7db5909f13931ebed04664f202940f371e2 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Fri, 8 May 2026 23:12:32 -0700 Subject: [PATCH] nix: add elegant grub2 theme package --- nixos/nix.nix | 1 + .../packages/elegant-grub2-theme/default.nix | 86 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 nixos/packages/elegant-grub2-theme/default.nix diff --git a/nixos/nix.nix b/nixos/nix.nix index 21c2869c..309c95f8 100644 --- a/nixos/nix.nix +++ b/nixos/nix.nix @@ -113,6 +113,7 @@ codex = inputs.codex-cli-nix.packages.${prev.stdenv.hostPlatform.system}.default; claude-code = inputs.claude-code-nix.packages.${prev.stdenv.hostPlatform.system}.default; git-sync-rs = inputs.git-sync-rs.packages.${prev.stdenv.hostPlatform.system}.default; + elegant-grub2-theme = final.callPackage ./packages/elegant-grub2-theme {}; kef = final.callPackage ./packages/kef {}; pykefcontrol = final.python3Packages.callPackage ./packages/pykefcontrol {}; roborock-control = final.callPackage ./packages/roborock-control {}; diff --git a/nixos/packages/elegant-grub2-theme/default.nix b/nixos/packages/elegant-grub2-theme/default.nix new file mode 100644 index 00000000..c00d9580 --- /dev/null +++ b/nixos/packages/elegant-grub2-theme/default.nix @@ -0,0 +1,86 @@ +{ + fetchFromGitHub, + imagemagick, + lib, + stdenvNoCC, + theme ? "wave", + style ? "window", + side ? "left", + color ? "dark", + screenVariant ? "1080p", + width ? null, + height ? null, +}: let + customResolution = width != null && height != null; + fontSizes = { + "1080p" = "16"; + "2k" = "24"; + "4k" = "32"; + }; + fontSize = builtins.getAttr screenVariant fontSizes; + themeName = + "Elegant-${theme}-${style}-${side}-${color}" + + lib.optionalString customResolution "-${width}x${height}"; +in + stdenvNoCC.mkDerivation { + pname = "elegant-grub2-theme"; + version = "2025-03-25"; + + src = fetchFromGitHub { + owner = "vinceliuice"; + repo = "Elegant-grub2-themes"; + rev = "2025-03-25"; + hash = "sha256-M9k6R/rUvEpBTSnZ2PMv5piV50rGTBrcmPU4gsS7Byg="; + }; + + nativeBuildInputs = lib.optional customResolution imagemagick; + + installPhase = + '' + runHook preInstall + + theme_dir="$out/share/grub/themes/${themeName}" + mkdir -p "$theme_dir" + + cp -a common/terminus*.pf2 "$theme_dir"/ + cp -a common/unifont-${fontSize}.pf2 "$theme_dir"/ + cp -a assets/assets-icons-${color}/icons-${color}-${screenVariant} "$theme_dir/icons" + cp -a config/theme-${style}-${side}-${color}-${screenVariant}.txt "$theme_dir/theme.txt" + cp -a assets/assets-other/other-${screenVariant}/select_e-${theme}-${color}.png "$theme_dir/select_e.png" + cp -a assets/assets-other/other-${screenVariant}/select_c-${theme}-${color}.png "$theme_dir/select_c.png" + cp -a assets/assets-other/other-${screenVariant}/select_w-${theme}-${color}.png "$theme_dir/select_w.png" + cp -a assets/assets-other/other-${screenVariant}/Default.png "$theme_dir/logo.png" + '' + + lib.optionalString customResolution '' + magick backgrounds/backgrounds-${theme}/background-${theme}-${style}-${side}-${color}.jpg \ + -resize ${width}x${height}^ \ + -gravity center \ + -extent ${width}x${height} \ + "$theme_dir/background.jpg" + magick assets/assets-other/other-${screenVariant}/${style}-${side}.png \ + -resize x${height} \ + -background none \ + -gravity west \ + -extent ${width}x${height} \ + "$theme_dir/info.png" + '' + + lib.optionalString (!customResolution) '' + cp -a backgrounds/backgrounds-${theme}/background-${theme}-${style}-${side}-${color}.jpg "$theme_dir/background.jpg" + cp -a assets/assets-other/other-${screenVariant}/${style}-${side}.png "$theme_dir/info.png" + '' + + '' + + runHook postInstall + ''; + + passthru = { + inherit themeName; + }; + + meta = { + description = "Elegant wave GRUB2 theme"; + homepage = "https://github.com/vinceliuice/Elegant-grub2-themes"; + license = lib.licenses.gpl3Only; + maintainers = []; + }; + }