From 0dd66b10886f3fc9cb390b43549163db635e41d3 Mon Sep 17 00:00:00 2001
From: zowoq <59103226+zowoq@users.noreply.github.com>
Date: Thu, 26 Dec 2024 10:28:09 +1000
Subject: [PATCH] Revert "modules/nixos/common/update: use
 grub.extraInstallCommands for boot diff"

This reverts commit 01137d599d5bccdb0f3399d51930534f0a7c05c3.
---
 modules/nixos/common/update.bash |  5 +++++
 modules/nixos/common/update.nix  | 11 +----------
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/modules/nixos/common/update.bash b/modules/nixos/common/update.bash
index 764a40d..fd823a7 100644
--- a/modules/nixos/common/update.bash
+++ b/modules/nixos/common/update.bash
@@ -12,6 +12,11 @@ nix-env --profile /nix/var/nix/profiles/system --set "$p"
 booted="$(readlink /run/booted-system/{initrd,kernel,kernel-modules} && cat /run/booted-system/kernel-params)"
 built="$(readlink "$p"/{initrd,kernel,kernel-modules} && cat "$p"/kernel-params)"
 if [[ $booted != "$built" ]]; then
+  if [[ -e /run/current-system ]]; then
+    echo "--- diff to current-system"
+    nvd diff /run/current-system "$p"
+    echo "---"
+  fi
   /nix/var/nix/profiles/system/bin/switch-to-configuration boot
   # don't use kexec if system is virtualized, reboots are fast enough
   if ! systemd-detect-virt -q; then
diff --git a/modules/nixos/common/update.nix b/modules/nixos/common/update.nix
index 60713fd..d8e30fd 100644
--- a/modules/nixos/common/update.nix
+++ b/modules/nixos/common/update.nix
@@ -16,20 +16,11 @@
       pkgs.coreutils
       pkgs.curl
       pkgs.kexec-tools
+      pkgs.nvd
     ];
     script = builtins.readFile ./update.bash;
   };
 
-  # https://gist.github.com/Ma27/6650d10f772511931647d3189b3eb1d7
-  # https://github.com/NuschtOS/nixos-modules/blob/39d26dddae2f117d7f9c33dd1efc866ff684ff94/modules/nix.nix
-  boot.loader.grub.extraInstallCommands = ''
-    if [[ "''${NIXOS_ACTION-}" == boot && -e /run/current-system && -e "''${1-}" ]]; then
-      echo "--- diff to current-system"
-      ${pkgs.nvd}/bin/nvd --nix-bin-dir=${config.nix.package}/bin diff /run/current-system "''${1-}"
-      echo "---"
-    fi
-  '';
-
   systemd.timers.update-host = {
     wantedBy = [ "timers.target" ];
     timerConfig.OnBootSec = "5m";