mirror of
https://github.com/gytis-ivaskevicius/flake-utils-plus.git
synced 2024-09-11 16:16:14 +03:00
21 lines
612 B
Nix
21 lines
612 B
Nix
{ writeShellScriptBin, coreutils, gnused }:
|
|
let
|
|
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
|
|
nix repl --file ${./repl.nix}
|
|
else
|
|
nix repl --arg flakePath $(${coreutils}/bin/readlink -f $1 | ${gnused}/bin/sed 's|/flake.nix||') --file ${./repl.nix}
|
|
fi
|
|
;;
|
|
esac
|
|
''
|