babashka: make rlwrap optional in wrapper

Fixes #246839
This commit is contained in:
José Luis Lafuente 2023-08-09 23:31:30 +02:00
parent 41c7605718
commit 2baf2502ea
No known key found for this signature in database
GPG key ID: 8A3455EBE455489A

View file

@ -1,12 +1,22 @@
{ stdenv
{ stdenvNoCC
, lib
, babashka-unwrapped
, clojure
, makeWrapper
, rlwrap
, jdkBabashka ? clojure.jdk
# rlwrap is a small utility to allow the editing of keyboard input, see
# https://book.babashka.org/#_repl
#
# NOTE In some cases, rlwrap prints some extra empty lines. That behavior can
# break some babashka scripts. For this reason, it is disabled by default. See:
# https://github.com/NixOS/nixpkgs/issues/246839
# https://github.com/NixOS/nixpkgs/pull/248207
, withRlwrap ? false
}:
stdenv.mkDerivation (finalAttrs: {
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "babashka";
inherit (babashka-unwrapped) version meta doInstallCheck installCheckPhase;
@ -27,6 +37,8 @@ stdenv.mkDerivation (finalAttrs: {
--set-default DEPS_CLJ_TOOLS_DIR $out/clojure_tools \
--set-default JAVA_HOME ${jdkBabashka}
'' +
lib.optionalString withRlwrap ''
substituteInPlace $out/bin/bb \
--replace '"${unwrapped-bin}"' '"${rlwrap}/bin/rlwrap" "${unwrapped-bin}"'
'';