Skip to content

Commit

Permalink
Extend logwatch-nixos-upgrade script
Browse files Browse the repository at this point in the history
  • Loading branch information
SFrijters committed Feb 6, 2024
1 parent d0414af commit 9a5b1f1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/logwatch-scripts/nixos-upgrade.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@ pkgs.writeShellApplication {
name = "logwatch-nixos-upgrade";
text = ''
package_update_regex="^ */nix/store"
keep_output_regex="updating lock file|updated input|github:NixOS/nixpkgs|will be built|will be fetched|^ /nix/store|switching to system configuration|NixOS Upgrade.|error: builder for"
keep_output_regex="updating lock file|will be built|will be fetched|^ /nix/store|switching to system configuration|NixOS Upgrade.|error: builder for"
updated_output_regex="updated input"
error_regex="error: builder for|Failed to start"
nprint=0
last=
while IFS= read -r line; do
if [[ "''${line}" =~ ''${package_update_regex} ]]; then
if [ "''${nprint}" -gt 0 ]; then
echo "''${line}"
nprint=$((nprint - 1))
elif [[ "''${line}" =~ ''${package_update_regex} ]]; then
# shellcheck disable=SC2001
package_name="$(echo "''${line}" | sed 's| */nix/store/[^\-]*-||')"
printf "%s " "''${package_name}"
last=package
elif [[ "''${line}" =~ ''${updated_output_regex} ]]; then
echo "''${line}"
nprint=2
elif [[ "''${line}" =~ ''${keep_output_regex} ]]; then
if [ "''${last}" = package ]; then
printf "\n"
Expand Down

0 comments on commit 9a5b1f1

Please sign in to comment.