From 6204949bdcd106a328fa9fccd779aa99a4753713 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Mon, 24 Nov 2025 16:43:12 -0500 Subject: [PATCH] nixpkgs: patching test --- ...eat-make-boot-messages-configureable.patch | 118 ++++++++++++++++++ flake.nix | 18 ++- 2 files changed, 132 insertions(+), 4 deletions(-) create mode 100644 0001-feat-make-boot-messages-configureable.patch diff --git a/0001-feat-make-boot-messages-configureable.patch b/0001-feat-make-boot-messages-configureable.patch new file mode 100644 index 0000000..f8005b6 --- /dev/null +++ b/0001-feat-make-boot-messages-configureable.patch @@ -0,0 +1,118 @@ +From 35d194ebf61d1fc29bc3759249dae5dd6096a5c0 Mon Sep 17 00:00:00 2001 +From: Simon Gardling +Date: Mon, 24 Nov 2025 15:06:26 -0500 +Subject: [PATCH] feat: make boot messages configureable + +--- + nixos/modules/system/boot/stage-1-init.sh | 4 ++-- + nixos/modules/system/boot/stage-1.nix | 21 ++++++++++++++++++++- + nixos/modules/system/boot/stage-2-init.sh | 2 +- + nixos/modules/system/boot/stage-2.nix | 11 ++++++++++- + 4 files changed, 33 insertions(+), 5 deletions(-) + +diff --git a/nixos/modules/system/boot/stage-1-init.sh b/nixos/modules/system/boot/stage-1-init.sh +index b8dbfb70c0bb..09ef663dbb6f 100644 +--- a/nixos/modules/system/boot/stage-1-init.sh ++++ b/nixos/modules/system/boot/stage-1-init.sh +@@ -73,7 +73,7 @@ trap 'fail' 0 + + # Print a greeting. + info +-info "<<< @distroName@ Stage 1 >>>" ++info "[1;32m@stage1Greeting@[0m" + info + + # Make several required directories. +@@ -445,7 +445,7 @@ lustrateRoot () { + local root="$1" + + echo +- echo -e "\e[1;33m<<< @distroName@ is now lustrating the root filesystem (cruft goes to /old-root) >>>\e[0m" ++ echo -e "\\e[1;33m@lustrateMessage@\\e[0m" + echo + + mkdir -m 0755 -p "$root/old-root.tmp" +diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix +index c87b3ecef4da..434e33ee8b70 100644 +--- a/nixos/modules/system/boot/stage-1.nix ++++ b/nixos/modules/system/boot/stage-1.nix +@@ -309,7 +309,8 @@ let + + inherit (config.boot) resumeDevice; + +- inherit (config.system.nixos) distroName; ++ stage1Greeting = config.boot.initrd.stage1Greeting; ++ lustrateMessage = config.boot.initrd.lustrateMessage; + + inherit (config.system.build) earlyMountScript; + +@@ -686,6 +687,24 @@ in + ''; + }; + ++ boot.initrd.stage1Greeting = mkOption { ++ type = types.str; ++ default = "<<< ${config.system.nixos.distroName} Stage 1 >>>"; ++ defaultText = lib.literalExpression ''"<<< ''${config.system.nixos.distroName} Stage 1 >>>"''; ++ description = '' ++ The greeting message displayed during NixOS stage 1 boot. ++ ''; ++ }; ++ ++ boot.initrd.lustrateMessage = mkOption { ++ type = types.str; ++ default = "<<< ${config.system.nixos.distroName} is now lustrating the root filesystem (cruft goes to /old-root) >>>"; ++ defaultText = lib.literalExpression ''"<<< ''${config.system.nixos.distroName} is now lustrating the root filesystem (cruft goes to /old-root) >>>"''; ++ description = '' ++ The message displayed when lustrating the root filesystem. ++ ''; ++ }; ++ + boot.loader.supportsInitrdSecrets = mkOption { + internal = true; + default = false; +diff --git a/nixos/modules/system/boot/stage-2-init.sh b/nixos/modules/system/boot/stage-2-init.sh +index e960f1bbcc39..c9884a719012 100755 +--- a/nixos/modules/system/boot/stage-2-init.sh ++++ b/nixos/modules/system/boot/stage-2-init.sh +@@ -19,7 +19,7 @@ if [ "${IN_NIXOS_SYSTEMD_STAGE1:-}" != true ]; then + + # Print a greeting. + echo +- echo -e "\e[1;32m<<< @distroName@ Stage 2 >>>\e[0m" ++ echo -e "\\e[1;32m@stage2Greeting@\\e[0m" + echo + + +diff --git a/nixos/modules/system/boot/stage-2.nix b/nixos/modules/system/boot/stage-2.nix +index 9565ac5e8ef1..993f4415cf24 100644 +--- a/nixos/modules/system/boot/stage-2.nix ++++ b/nixos/modules/system/boot/stage-2.nix +@@ -19,7 +19,7 @@ let + systemConfig = null; # replaced in ../activation/top-level.nix + inherit (config.boot) systemdExecutable; + nixStoreMountOpts = lib.concatStringsSep " " (map lib.escapeShellArg config.boot.nixStoreMountOpts); +- inherit (config.system.nixos) distroName; ++ stage2Greeting = config.boot.stage2Greeting; + inherit useHostResolvConf; + inherit (config.system.build) earlyMountScript; + path = lib.makeBinPath ( +@@ -87,6 +87,15 @@ in + ''; + }; + ++ stage2Greeting = mkOption { ++ type = types.str; ++ default = "<<< ${config.system.nixos.distroName} Stage 2 >>>"; ++ defaultText = lib.literalExpression ''"<<< ''${config.system.nixos.distroName} Stage 2 >>>"''; ++ description = '' ++ The greeting message displayed during NixOS stage 2 boot. ++ ''; ++ }; ++ + extraSystemdUnitPaths = mkOption { + default = [ ]; + type = types.listOf types.str; +-- +2.51.2 + diff --git a/flake.nix b/flake.nix index 2bfd51a..3518bac 100644 --- a/flake.nix +++ b/flake.nix @@ -70,7 +70,6 @@ outputs = { self, - nixpkgs, lanzaboote, nixos-hardware, home-manager, @@ -86,15 +85,26 @@ "yarn" ]; niri-package = inputs.niri.packages.${system}.niri-unstable; + + patchedNixpkgsSrc = (import inputs.nixpkgs { inherit system; }).applyPatches { + name = "nixpkgs-patched"; + src = inputs.nixpkgs; + patches = [ ./0001-feat-make-boot-messages-configureable.patch ]; + }; + + patchedNixpkgs = import patchedNixpkgsSrc { inherit system; }; in { - formatter.${system} = nixpkgs.legacyPackages.${system}.nixfmt-rfc-style; + formatter.${system} = patchedNixpkgs.nixfmt-rfc-style; - nixosConfigurations = nixpkgs.lib.foldl' ( + nixosConfigurations = patchedNixpkgs.lib.foldl' ( config: hostname: config // { - "${hostname}" = nixpkgs.lib.nixosSystem { + "${hostname}" = import "${patchedNixpkgsSrc}/nixos/lib/eval-config.nix" { + lib = patchedNixpkgs.lib; + baseModules = import "${patchedNixpkgsSrc}/nixos/modules/module-list.nix"; + inherit system; specialArgs = { inherit inputs