From 63fc603f07ff10a459427e9cda1803f947061952 Mon Sep 17 00:00:00 2001 From: Myned Date: Fri, 6 Dec 2024 19:44:03 -0600 Subject: [PATCH] sudo: add confirmation prompt Signed-off-by: Myned --- options/custom/settings/security.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/options/custom/settings/security.nix b/options/custom/settings/security.nix index a621f0c..2721b67 100644 --- a/options/custom/settings/security.nix +++ b/options/custom/settings/security.nix @@ -1,6 +1,7 @@ { config, lib, + pkgs, ... }: with lib; let @@ -25,5 +26,21 @@ in { ''; }; }; + + environment.shellAliases = { + # Sudo confirmation prompt + sudo = pkgs.writeShellScript "sudo" '' + read -p "Execute as root? [Y/n] " + + case "$REPLY" in + "" | [Yy]) + command sudo "$@" + ;; + *) + exit 1 + ;; + esac + ''; + }; }; }