Update env

This commit is contained in:
Porta 2026-10-22 17:29:36 +10:00
parent 37baf240ab
commit 4ccddab132
No known key found for this signature in database
5 changed files with 196 additions and 0 deletions

View file

@ -12,6 +12,8 @@
# machine hardware and settings
fractal-configuration
fractal-hardware
inputs.double-minegrub-menu.inputs.minegrub-world-sel-theme.nixosModules.default
double-minegrub-menu
# selected features for this desktop
network-proxy
@ -45,12 +47,20 @@
enable = true;
device = "nodev";
efiSupport = true;
double-minegrub-menu = {
enable = true;
main_menu_background = "random";
splash_text = "100% Declarative";
world_selection_background_scaled = "1920x1080";
};
};
efi.canTouchEfiVariables = true;
timeout = lib.mkDefault 5;
};
initrd.systemd.enable = true;
};
# Minegrub supplies its own GRUB theme; don't layer Stylix's GRUB theme over it.
stylix.targets.grub.enable = false;
hardware.enableRedistributableFirmware = true;
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;

View file

@ -0,0 +1,117 @@
{ ... }:
{
flake.nixosModules.double-minegrub-menu =
{ config, lib, pkgs, ... }:
let
cfg = config.boot.loader.grub.double-minegrub-menu;
backgroundArg =
if cfg.main_menu_background == "random" then ""
else "backgrounds/${cfg.main_menu_background}";
splashTextArg = if cfg.splash_text == "random" then "" else cfg.splash_text;
minegrubTheme = pkgs.fetchFromGitHub {
owner = "Lxtharia";
repo = "minegrub-theme";
rev = "v3.1.0";
# Correct source hash for v3.1.0 (the upstream module's hash is stale).
hash = "sha256-+7b0jXVVAyIAtYKeZZONZv2qzfESjwITSng1TVjyAfQ=";
};
pythonEnv = pkgs.python313.withPackages (pythonPackages: [ pythonPackages.pillow ]);
fakeFastfetch = pkgs.writeShellScriptBin "fastfetch" ''
package_count=$(ls -d /nix/var/nix/profiles/system/sw/bin/* 2>/dev/null | wc -l)
echo "Packages: $package_count (nix)"
'';
minegrubUpdate = pkgs.writeShellScriptBin "minegrub-update" ''
cd /boot/grub/themes/minegrub
export PATH="${fakeFastfetch}/bin:${pythonEnv}/bin:$PATH"
exec ${pythonEnv}/bin/python3 update_theme.py \
${lib.escapeShellArg backgroundArg} \
${lib.escapeShellArg splashTextArg}
'';
themeDir = "${minegrubTheme}/minegrub";
backgroundDir = "${minegrubTheme}/background_options";
themeFiles = builtins.listToAttrs (map
(file: {
name = builtins.unsafeDiscardStringContext
("grub/themes/minegrub" + lib.removePrefix (toString themeDir) (toString file));
value = file;
})
(lib.filesystem.listFilesRecursive themeDir));
backgroundFiles = builtins.listToAttrs (map
(file: {
name = builtins.unsafeDiscardStringContext
("grub/themes/minegrub/backgrounds" + lib.removePrefix (toString backgroundDir) (toString file));
value = file;
})
(lib.filesystem.listFilesRecursive backgroundDir));
in
{
options.boot.loader.grub.double-minegrub-menu = {
enable = lib.mkEnableOption "the Minegrub double menu";
main_menu_background = lib.mkOption {
type = lib.types.str;
default = "random";
description = "Main menu background asset, or random.";
};
splash_text = lib.mkOption {
type = lib.types.str;
default = "random";
description = "Main menu splash text, or random.";
};
world_selection_custom_icons = lib.mkOption {
type = lib.types.listOf (lib.types.attrsOf lib.types.anything);
default = [ ];
description = "Custom icons for the world-selection menu.";
};
world_selection_background_scaled = lib.mkOption {
type = lib.types.str;
default = "1920x1080";
description = "World-selection background resolution.";
};
};
config = lib.mkIf cfg.enable {
boot.loader.grub = {
minegrub-world-sel = {
enable = true;
customIcons = cfg.world_selection_custom_icons;
background = "assets/background-scaled/background-${cfg.world_selection_background_scaled}.png";
};
extraFiles = {
"grub/mainmenu.cfg" = ./mainmenu.cfg;
} // themeFiles // backgroundFiles;
extraConfig = ''
if [ -z "$chosen" ] ; then
if [ "''${config_file}" ] ; then
configfile $prefix/$config_file
fi
fi
'';
};
environment.systemPackages = [ minegrubUpdate ];
systemd.services.minegrub-update = {
description = "Update Minegrub splash text and background";
after = [ "local-fs.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = "${minegrubUpdate}/bin/minegrub-update";
User = "root";
};
};
# Set the GRUB environment variable needed to select the main menu.
system.activationScripts.minegrub-menu = {
deps = [ "specialfs" ];
text = ''
${pkgs.grub2}/bin/grub-editenv - set config_file=mainmenu.cfg
'';
};
};
};
}

View file

@ -0,0 +1,20 @@
loadfont $prefix/themes/minegrub/Minecraft30.pf2
loadfont $prefix/themes/minegrub/Monocraft22.pf2
insmod png
set theme=$prefix/themes/minegrub/theme.txt
export theme
set timeout_style=menu
set timeout=15
menuentry " Singlebooter" {
configfile $prefix/grub.cfg
}
menuentry " Onlinebooter" {
echo "I don't know how network boot works"
}
menuentry " Uefi Setting Realm" $menuentry_id_option 'uefi-firmware' {
fwsetup
}