summaryrefslogtreecommitdiff
path: root/modules/nixos/custom/nvd-diff.nix
blob: 0e88d1069e634a27363719cad1f5fd0c89dbc6e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
  config,
  lib,
  pkgs,
  ...
}:

let
  cfg = config.borealis.nvd-diff;
in

{
  options.borealis.nvd-diff = {
    enable = lib.mkEnableOption "`nvd` to show configuration diffs on upgrade";
  };

  config = lib.mkIf cfg.enable {
    system.activationScripts."upgrade-diff" = {
      supportsDryActivation = true;

      text = ''
        ${lib.getExe pkgs.nvd} \
          --nix-bin-dir=${config.nix.package}/bin \
          diff /run/current-system "$systemConfig"
      '';
    };
  };
}