Skip to content

Commit

Permalink
feat!: only show diff when nh is not being used
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelroses committed Sep 30, 2024
1 parent 99a109f commit 586b52d
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions modules/base/activation/diff.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@ let
inherit (lib.options) mkEnableOption;
in
{
# NOTE: this is not enabled by default because we have nh, which does the same
options.garden.system.activation.diff.enable = mkEnableOption "Enable a system diff";
options.garden.system.activation.diff.enable = mkEnableOption "Enable a system diff" // {
default = !config.programs.nh.enable;
};

# if the system supports dry activation, this means that we can compare
# the current system with the one we are about to switch to
# this can be useful to see what will change, and the clousure size
config.system.activationScripts.diff = mkIf config.garden.system.activation.diff.enable {
supportsDryActivation = true;
text = ''
if [[ -e /run/current-system ]]; then
echo "=== diff to current-system ==="
${pkgs.nvd}/bin/nvd --nix-bin-dir='${config.nix.package}/bin' diff /run/current-system "$systemConfig"
echo "=== end of the system diff ==="
fi
'';
};
config.system.activationScripts.diff =
mkIf (config.garden.system.activation.diff.enable && !config.programs.nh.enable)
{
supportsDryActivation = true;
text = ''
if [[ -e /run/current-system ]]; then
echo "=== diff to current-system ==="
${pkgs.nvd}/bin/nvd --nix-bin-dir='${config.nix.package}/bin' diff /run/current-system "$systemConfig"
echo "=== end of the system diff ==="
fi
'';
};
}

0 comments on commit 586b52d

Please sign in to comment.