Moved scripts to the overlay folder to be used as packages

All scripts have been moved to the overlay folder in the top level directory

Overlay is now instantiated per configuration to make use of the host variable
This commit is contained in:
2024-11-16 03:42:07 -05:00
parent 2a2263d4cb
commit 8c007c3915
27 changed files with 200 additions and 175 deletions

View File

@@ -0,0 +1,27 @@
{ pkgs, }:
pkgs.writeShellApplication {
name = "runbg";
runtimeInputs = with pkgs; [
coreutils # Provides `basename`, `which`, etc.
bash # Provides the Bash shell
util-linux # Provides `tty`
];
text = ''
#!/usr/bin/env bash
[ $# -eq 0 ] && { # $# is number of args
echo "$(basename "$0"): missing command" >&2
exit 1
}
prog="$(which "$1")" # see below
[ -z "$prog" ] && {
echo "$(basename "$0"): unknown command: $1" >&2
exit 1
}
shift # remove $1, now $prog, from args
tty -s && exec </dev/null # if stdin is a terminal, redirect from null
tty -s <&1 && exec >/dev/null # if stdout is a terminal, redirect to null
tty -s <&2 && exec 2>&1 # stderr to stdout (which might not be null)
"$prog" "$@" & # $@ is all args
'';
}