From d877ffc76ce0976ec829ec23bd7f5328c26e5240 Mon Sep 17 00:00:00 2001 From: moons Date: Wed, 5 Aug 2026 01:40:18 +0900 Subject: [PATCH] nh --- modules/applications/nh/home.nix | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/modules/applications/nh/home.nix b/modules/applications/nh/home.nix index f89ca91..42d66b5 100644 --- a/modules/applications/nh/home.nix +++ b/modules/applications/nh/home.nix @@ -5,4 +5,38 @@ NH_FLAKE = "${config.home.homeDirectory}/dotfiles"; NH_SHOW_ACTIVATION_LOGS = "1"; }; + + programs.zsh.initContent = '' + export SUDO_PROMPT=$'\a[sudo] authenticate for %u: ' + + nh() { + local notify=false + local argument + + case "$1:$2" in + os:switch | os:build) notify=true ;; + esac + + for argument in "$@"; do + if [[ "$argument" == "--update" ]]; then + notify=true + break + fi + done + + command nh "$@" + local status=$? + + if [[ "$notify" == true ]]; then + printf '\a' + if ((status == 0)); then + print -P "%F{green}nh completed%f" + else + print -P "%F{red}nh failed (exit $status)%f" + fi + fi + + return "$status" + } + ''; }