From 4ccddab1323f6daf4740b8d8934d012cf6bf1494 Mon Sep 17 00:00:00 2001 From: Porta Date: Thu, 22 Oct 2026 17:29:36 +1000 Subject: [PATCH] Update env --- flake.lock | 43 +++++++ flake.nix | 6 + modules/system/hosts/fractal/default.nix | 10 ++ .../hosts/fractal/double-minegrub-menu.nix | 117 ++++++++++++++++++ modules/system/hosts/fractal/mainmenu.cfg | 20 +++ 5 files changed, 196 insertions(+) create mode 100644 modules/system/hosts/fractal/double-minegrub-menu.nix create mode 100644 modules/system/hosts/fractal/mainmenu.cfg diff --git a/flake.lock b/flake.lock index e91ee15..ffe1939 100755 --- a/flake.lock +++ b/flake.lock @@ -68,6 +68,27 @@ "type": "github" } }, + "double-minegrub-menu": { + "inputs": { + "minegrub-world-sel-theme": "minegrub-world-sel-theme", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1792109327, + "narHash": "sha256-VhZ4Jw6xmvnIo+thPoWIr7SOILDVPkWTWMqlbB30doE=", + "owner": "Lxtharia", + "repo": "double-minegrub-menu", + "rev": "c10fd20713db2f002645a4c709b153964cac77cd", + "type": "github" + }, + "original": { + "owner": "Lxtharia", + "repo": "double-minegrub-menu", + "type": "github" + } + }, "firefox-gnome-theme": { "flake": false, "locked": { @@ -291,6 +312,27 @@ "type": "github" } }, + "minegrub-world-sel-theme": { + "inputs": { + "nixpkgs": [ + "double-minegrub-menu", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1791975566, + "narHash": "sha256-4zW6sdKTDLX599XR4elbEa3jUySDD0j3y3EMJdyorKg=", + "owner": "Lxtharia", + "repo": "minegrub-world-sel-theme", + "rev": "556211de8a2de580d6cb9a14f0bf3b85c851df1f", + "type": "github" + }, + "original": { + "owner": "Lxtharia", + "repo": "minegrub-world-sel-theme", + "type": "github" + } + }, "mkdocs-catppuccin": { "flake": false, "locked": { @@ -554,6 +596,7 @@ }, "root": { "inputs": { + "double-minegrub-menu": "double-minegrub-menu", "flake-parts": "flake-parts", "hardware": "hardware", "helix-plugins": "helix-plugins", diff --git a/flake.nix b/flake.nix index 21c0066..aa54c70 100755 --- a/flake.nix +++ b/flake.nix @@ -25,6 +25,12 @@ # nix hardware - https://github.com/NixOS/nixos-hardware hardware.url = "github:nixos/nixos-hardware"; + # Minecraft-themed GRUB double-menu module + double-minegrub-menu = { + url = "github:Lxtharia/double-minegrub-menu"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + # dendritic stuff - https://github.com/mightyiam/dendritic # flake parts - https://github.com/hercules-ci/flake-parts # import tree - https://github.com/denful/import-tree diff --git a/modules/system/hosts/fractal/default.nix b/modules/system/hosts/fractal/default.nix index 8e25294..eba9fe4 100644 --- a/modules/system/hosts/fractal/default.nix +++ b/modules/system/hosts/fractal/default.nix @@ -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; diff --git a/modules/system/hosts/fractal/double-minegrub-menu.nix b/modules/system/hosts/fractal/double-minegrub-menu.nix new file mode 100644 index 0000000..4c6a314 --- /dev/null +++ b/modules/system/hosts/fractal/double-minegrub-menu.nix @@ -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 + ''; + }; + }; + }; +} diff --git a/modules/system/hosts/fractal/mainmenu.cfg b/modules/system/hosts/fractal/mainmenu.cfg new file mode 100644 index 0000000..7f41920 --- /dev/null +++ b/modules/system/hosts/fractal/mainmenu.cfg @@ -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 +}