From a2d2812bd2414796ad2df734e43a52b1824ac4b3 Mon Sep 17 00:00:00 2001 From: Abhinav Sarkar Date: Thu, 27 Oct 2022 11:31:08 +0530 Subject: [PATCH] Adds report-hm-changes script --- home.nix | 2 +- justfile | 1 + scripts/default.nix | 7 +++++++ scripts/report-hm-changes.nix | 13 +++++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 scripts/default.nix create mode 100644 scripts/report-hm-changes.nix diff --git a/home.nix b/home.nix index f4b41a8..d92f0a1 100644 --- a/home.nix +++ b/home.nix @@ -1,7 +1,7 @@ { config, pkgs, ... }: { - imports = [ ./programs ./launchd.nix ./nix.nix ]; + imports = [ ./programs ./scripts ./launchd.nix ./nix.nix ]; home.username = "abhinav"; home.homeDirectory = "/Users/abhinav"; diff --git a/justfile b/justfile index 59df00d..03372d0 100644 --- a/justfile +++ b/justfile @@ -25,6 +25,7 @@ build: (_run "_build") _switch: home-manager -v switch --flake "{{ root_dir }}#abhinav" + report-hm-changes # switch to latest home-manager generation switch: (_run "_switch") diff --git a/scripts/default.nix b/scripts/default.nix new file mode 100644 index 0000000..e6716f9 --- /dev/null +++ b/scripts/default.nix @@ -0,0 +1,7 @@ +{ config, lib, pkgs, ... }: + +let + rc = pkgs.callPackage ./report-hm-changes.nix { inherit config pkgs; }; +in { + home.packages = [ rc ]; +} diff --git a/scripts/report-hm-changes.nix b/scripts/report-hm-changes.nix new file mode 100644 index 0000000..ec4d3b0 --- /dev/null +++ b/scripts/report-hm-changes.nix @@ -0,0 +1,13 @@ +{ config, pkgs, ... }: + +let + profiles = "/nix/var/nix/profiles/per-user/${config.home.username}/home-manager-*-link"; +in +pkgs.writeShellScriptBin "report-hm-changes" '' + # Disable nvd if there are less than 2 hm profiles. + if [ $(ls -d1v ${profiles} 2>/dev/null | wc -l) -lt 2 ]; then + echo "Skipping changes report..." + else + ${pkgs.nvd}/bin/nvd diff $(ls -d1v ${profiles} | tail -2) + fi +''