grace/dots
dotfiles/nix configs
git clone https://git.gae.moe/grace/dots
b70d9f9
main
1{ 2config , 3lib , 4pkgs , 5 ... 6} : 7 8let 9notify = pkgs . writeShellScript "notify-nixos-switch" '' 10credentials =/etc/secrets/ntfy-nixos-switch.curl 11if [ ! -r " $ credentials " ]; then 12exit 0 13fi 14 15printf 'Successfully switched %s to %s\n' \ 16${ lib . escapeShellArg config . networking . hostName } \ 17"$( ${ pkgs . coreutils } /bin/readlink -f /run/current-system)" | 18${ pkgs . curl } /bin/curl \ 19--config " $ credentials " \ 20--fail --silent --show-error \ 21--connect-timeout 3 --max-time 10 \ 22--header ${ lib . escapeShellArg "Title: ${ config . networking . hostName } : NixOS switch succeeded" } \ 23--data-binary @- \ 24--output /dev/null \ 25https://ntfy.gae.moe/nixos 26'' ; 27 28switch = pkgs . writeShellScript "switch-to-configuration-notify" '' 29"'' $ { 0%/*}/switch-to-configuration-unnotified " " $ @ " 30status= $ ? 31if [ " $ status " -eq 0 ] && [ "'' $ { 1:-} " = switch ]; then 32"'' $ {0%/*}/notify-nixos-switch" || true 33fi 34exit " $ status " 35'' ; 36in 37{ 38config = lib . mkIf config . system . switch . enable { 39system . activatableSystemBuilderCommands = lib . mkAfter '' 40mv "$out/bin/switch-to-configuration" "$out/bin/switch-to-configuration-unnotified" 41ln -s ${ notify } "$out/bin/notify-nixos-switch" 42ln -s ${ switch } "$out/bin/switch-to-configuration" 43'' ; 44}; 45}