aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/sw/swallow/swallow.sh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xpkgs/by-name/sw/sw/sw.sh (renamed from pkgs/by-name/sw/swallow/swallow.sh)34
1 files changed, 29 insertions, 5 deletions
diff --git a/pkgs/by-name/sw/swallow/swallow.sh b/pkgs/by-name/sw/sw/sw.sh
index ac1858ea..f71f65ee 100755
--- a/pkgs/by-name/sw/swallow/swallow.sh
+++ b/pkgs/by-name/sw/sw/sw.sh
@@ -14,12 +14,36 @@ throwup() {
riverctl focus-previous-tags
}
+swallow() {
+ # Make sure that we actually `throwup`, when the command fails
+ set +e
+
+ eat && "$@"
+ throwup
+
+ set -e
+}
+
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"
+ printf "sw: No arguments supplied\n"
+ exit 2
else
- eat && "$@"
+ case "$1" in
+ "-n" | "--nix")
+ shift 1
+ [ -z "$1" ] && {
+ printf "sw: --nix requires a nix installible\n"
+ exit 2
+ }
+
+ # Build it first, so the user still sees a progress bar
+ nix build --no-link "n#$1"
+
+ swallow nix run "n#$1"
+ ;;
+ *)
+ swallow "$@"
+ ;;
+ esac
- throwup
fi