From 92def64fea532e0735a258619aaf8cfdb8e42ebe Mon Sep 17 00:00:00 2001 From: yukkop Date: Thu, 17 Jul 2025 16:22:31 +0000 Subject: [PATCH] feat(lib): `shell`: +check-tool --- lib/default.nix | 5 ++++- lib/shell/check-tool.sh | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 lib/shell/check-tool.sh diff --git a/lib/default.nix b/lib/default.nix index 3f4bc45..9b6eef9 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -48,7 +48,10 @@ in { forSystems = systems: nixpkgs.lib.genAttrs systems; forAllSystems = nixpkgs.lib.genAttrs commonSystems; - shellModules.logs = builtins.readFile ./shell/logs.sh; + shellModules = { + logs = builtins.readFile ./shell/logs.sh; + check-tool = builtins.readFile ./shell/check-tool.sh; + }; sharedShellAliases = { jc = ''journalctl''; diff --git a/lib/shell/check-tool.sh b/lib/shell/check-tool.sh new file mode 100644 index 0000000..c2f120d --- /dev/null +++ b/lib/shell/check-tool.sh @@ -0,0 +1,6 @@ +check_tool() { + if ! command -v "$1" >/dev/null; then + echo "Required tool \`$2\` are not installed or binary \`$1\` not found." >&2 + exit 1 + fi +}