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,
|
|
|
|
writeShellScriptBin,
|
2023-12-31 15:44:53 -05:00
|
|
|
...
|
2023-12-02 14:32:48 -05:00
|
|
|
}: let
|
|
|
|
repl = ./repl.nix;
|
|
|
|
example = command: desc: ''\n\u001b[33m ${command}\u001b[0m - ${desc}'';
|
|
|
|
in
|
|
|
|
writeShellScriptBin "repl" ''
|
|
|
|
case "$1" in
|
|
|
|
"-h"|"--help"|"help")
|
|
|
|
printf "%b\n\e[4mUsage\e[0m: \
|
|
|
|
${example "repl" "Loads system flake if available."} \
|
|
|
|
${example "repl /path/to/flake.nix" "Loads specified flake."}\n"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
if [ -z "$1" ]; then
|
2024-06-08 22:21:04 -04:00
|
|
|
nix repl --arg flakePath $(${coreutils}/bin/readlink -f "$FLAKE") --file ${repl}
|
2023-12-02 14:32:48 -05:00
|
|
|
else
|
2023-12-15 15:11:14 -05:00
|
|
|
nix repl --arg flakePath $(${coreutils}/bin/readlink -f $1 | ${gnused}/bin/sed 's|/flake.nix||') --file ${repl}
|
2023-12-02 14:32:48 -05:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
''
|