mirror of
https://github.com/vinceliuice/grub2-themes.git
synced 2024-12-25 06:45:35 +01:00
commit
a4bff7bf91
119
flake.nix
Normal file
119
flake.nix
Normal file
@ -0,0 +1,119 @@
|
||||
{
|
||||
description = "Flake to manage grub2 themes from vinceliuice";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/master";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
};
|
||||
in
|
||||
with nixpkgs.lib;
|
||||
rec {
|
||||
nixosModule = { config, ... }:
|
||||
let
|
||||
cfg = config.boot.loader.grub2-theme;
|
||||
resolutions = {
|
||||
"1080p" = "1920x1080";
|
||||
"ultrawide" = "2560x1080";
|
||||
"2k" = "2560x1440";
|
||||
"4k" = "3840x2160";
|
||||
"ultrawide2k" = "3440x1440";
|
||||
};
|
||||
grub2-theme = pkgs.stdenv.mkDerivation {
|
||||
name = "grub2-theme";
|
||||
src = "${self}";
|
||||
installPhase = ''
|
||||
mkdir -p $out/grub/themes;
|
||||
bash ./install.sh \
|
||||
--generate $out/grub/themes \
|
||||
--screen ${cfg.screen} \
|
||||
--theme ${cfg.theme} \
|
||||
--icon ${cfg.icon};
|
||||
|
||||
if [ -f ${cfg.splashImage} ]; then
|
||||
cp ${cfg.splashImage} $out/grub/themes/${cfg.theme}/background.jpg;
|
||||
fi;
|
||||
if [ ${pkgs.lib.trivial.boolToString cfg.footer} == "false" ]; then
|
||||
sed -i ':again;$!N;$!b again; s/\+ image {[^}]*}//g' $out/grub/themes/${cfg.theme}/theme.txt;
|
||||
fi;
|
||||
'';
|
||||
};
|
||||
resolution = resolutions."${cfg.screen}";
|
||||
in
|
||||
rec {
|
||||
options = {
|
||||
boot.loader.grub2-theme = {
|
||||
enable = mkOption {
|
||||
default = true;
|
||||
example = true;
|
||||
type = types.bool;
|
||||
description = ''
|
||||
Enable grub2 theming
|
||||
'';
|
||||
};
|
||||
theme = mkOption {
|
||||
default = "tela";
|
||||
example = "tela";
|
||||
type = types.enum [ "tela" "vimix" "stylish" "whitesur" ];
|
||||
description = ''
|
||||
The theme to use for grub2.
|
||||
'';
|
||||
};
|
||||
icon = mkOption {
|
||||
default = "white";
|
||||
example = "white";
|
||||
type = types.enum [ "color" "white" "whitesur" ];
|
||||
description = ''
|
||||
The icon to use for grub2.
|
||||
'';
|
||||
};
|
||||
screen = mkOption {
|
||||
default = "1080p";
|
||||
example = "1080p";
|
||||
type = types.enum [ "1080p" "2k" "4k" "ultrawide" "ultrawide2k" ];
|
||||
description = ''
|
||||
The screen resolution to use for grub2.
|
||||
'';
|
||||
};
|
||||
splashImage = mkOption {
|
||||
default = "";
|
||||
example = "/my/path/background.jpg";
|
||||
type = types.path;
|
||||
description = ''
|
||||
The path of the image to use for background (must be jpg).
|
||||
'';
|
||||
};
|
||||
footer = mkOption {
|
||||
default = true;
|
||||
example = true;
|
||||
type = types.bool;
|
||||
description = ''
|
||||
Whether to include the image footer.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
config = mkIf cfg.enable (mkMerge [{
|
||||
environment.systemPackages = [
|
||||
grub2-theme
|
||||
];
|
||||
boot.loader.grub = {
|
||||
theme = "${grub2-theme}/grub/themes/${cfg.theme}";
|
||||
splashImage = "${grub2-theme}/grub/themes/${cfg.theme}/background.jpg";
|
||||
gfxmodeEfi = "${resolution},auto";
|
||||
gfxmodeBios = "${resolution},auto";
|
||||
extraConfig = ''
|
||||
insmod gfxterm
|
||||
insmod png
|
||||
set icondir=($root)/theme/icons
|
||||
'';
|
||||
};
|
||||
}]);
|
||||
};
|
||||
};
|
||||
}
|
@ -69,8 +69,6 @@ usage() {
|
||||
}
|
||||
|
||||
generate() {
|
||||
clear
|
||||
|
||||
# Make a themes directory if it doesn't exist
|
||||
prompt -s "\n Checking for the existence of themes directory..."
|
||||
|
||||
@ -115,6 +113,8 @@ install() {
|
||||
|
||||
# Check for root access and proceed if it is present
|
||||
if [[ "$UID" -eq "$ROOT_UID" ]]; then
|
||||
clear
|
||||
|
||||
# Generate the theme in "/usr/share/grub/themes"
|
||||
generate "${theme}" "${icon}" "${screen}"
|
||||
|
||||
@ -599,4 +599,4 @@ if [[ "${dialog:-}" == 'false' ]]; then
|
||||
dialog_installer
|
||||
fi
|
||||
|
||||
exit 1
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user