2024-06-26 14:47:14 -04:00
|
|
|
# modified from https://github.com/fufexan/dotfiles/blob/main/pkgs/repl/default.nix
|
2023-12-02 14:32:48 -05:00
|
|
|
{
|
|
|
|
coreutils,
|
|
|
|
gnused,
|
2024-11-21 12:59:47 -05:00
|
|
|
ncurses,
|
|
|
|
writeShellApplication,
|
2023-12-31 15:44:53 -05:00
|
|
|
...
|
2023-12-02 14:32:48 -05:00
|
|
|
}: let
|
|
|
|
repl = ./repl.nix;
|
2024-11-21 12:59:47 -05:00
|
|
|
example = command: desc: ''\n$(tput setaf 3) ${command}$(tput sgr0) - ${desc}'';
|
2023-12-02 14:32:48 -05:00
|
|
|
in
|
2024-11-21 12:59:47 -05:00
|
|
|
writeShellApplication {
|
|
|
|
name = "repl";
|
|
|
|
|
|
|
|
runtimeInputs = [coreutils gnused ncurses];
|
|
|
|
|
|
|
|
text = ''
|
|
|
|
arg=''${1:-"."}
|
|
|
|
|
|
|
|
case "$arg" in
|
|
|
|
"-h"|"--help"|"help")
|
|
|
|
# shellcheck disable=SC2059
|
|
|
|
printf "\n\e[4mUsage\e[0m: \
|
|
|
|
${example "repl " "Loads system flake present at $(tput setaf 4)\\$FLAKE$(tput sgr0)."} \
|
|
|
|
${example "repl <flake path>" "Loads specified flake."}\n"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
if [ -z "$arg" ]; then
|
|
|
|
nix repl \
|
|
|
|
--arg flakePath "$(realpath "$FLAKE")" \
|
|
|
|
--file ${repl}
|
|
|
|
else
|
|
|
|
nix repl \
|
|
|
|
--arg flakePath "$(realpath "$arg" | sed 's|/flake.nix||')" \
|
|
|
|
--file ${repl}
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
'';
|
|
|
|
}
|