aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-07-11 17:18:33 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-07-16 17:49:39 +0200
commit11c7421af599aaa5ca7ad7fd900c1fe70b206229 (patch)
treefc81ec381bf1be1caba762bd2c4abd730769eee6
parentpkgs/swallow: Rename to `sw` (diff)
downloadnixos-config-11c7421af599aaa5ca7ad7fd900c1fe70b206229.zip
pkgs/sw: Support a nix specific swallow mode
Diffstat (limited to '')
-rwxr-xr-xpkgs/by-name/sw/sw/sw.sh29
1 files changed, 23 insertions, 6 deletions
diff --git a/pkgs/by-name/sw/sw/sw.sh b/pkgs/by-name/sw/sw/sw.sh
index 68dd6a75..a62bfcbb 100755
--- a/pkgs/by-name/sw/sw/sw.sh
+++ b/pkgs/by-name/sw/sw/sw.sh
@@ -14,15 +14,32 @@ throwup() {
riverctl focus-previous-tags
}
-if [ -z "$*" ]; then
- printf "ERROR: No arguments supplied\n"
-elif ! command -v "$1" >/dev/null; then
- printf "ERROR: Command '%s' does not exist\n" "$1"
-else
+swallow() {
# Make sure that we actually `throwup`, when the command fails
set +e
eat && "$@"
-
throwup
+
+ set -e
+}
+
+if [ -z "$*" ]; then
+ printf "sw: No arguments supplied\n"
+ exit 2
+else
+ case "$1" in
+ "-n" | "--nix")
+ shift 1
+ [ -z "$1" ] && {
+ printf "sw: --nix requires a nix installible\n"
+ exit 2
+ }
+ swallow nix run "n#$1"
+ ;;
+ *)
+ swallow "$@"
+ ;;
+ esac
+
fi