Adds report-hm-changes script

nix-darwin
Abhinav Sarkar 2022-10-27 11:31:08 +05:30
parent 9976991058
commit a2d2812bd2
4 changed files with 22 additions and 1 deletions

View File

@ -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";

View File

@ -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")

7
scripts/default.nix Normal file
View File

@ -0,0 +1,7 @@
{ config, lib, pkgs, ... }:
let
rc = pkgs.callPackage ./report-hm-changes.nix { inherit config pkgs; };
in {
home.packages = [ rc ];
}

View File

@ -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
''