nixos-configs/pkgs/repl/default.nix
matt1432 fc712b5223
All checks were successful
Discord / discord commits (push) Has been skipped
refactor: move mpv scripts and firefox addons to scopes in lgcyPkgs
2024-06-26 14:47:14 -04:00

27 lines
807 B
Nix

# modified from https://github.com/fufexan/dotfiles/blob/main/pkgs/repl/default.nix
{
coreutils,
gnused,
writeShellScriptBin,
...
}: 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
nix repl --arg flakePath $(${coreutils}/bin/readlink -f "$FLAKE") --file ${repl}
else
nix repl --arg flakePath $(${coreutils}/bin/readlink -f $1 | ${gnused}/bin/sed 's|/flake.nix||') --file ${repl}
fi
;;
esac
''