broot: fix nushell integration br command
broot 1.51 renamed the printed nushell entry point from `br` to `main`, intended to be loaded with `use` where the command takes the module's name. Home Manager sources the snippet with `source`, so it began defining a global `main` instead of `br`, breaking the `br` command in nushell. Rewrite the definition line back to `br` for the nushell shell function so `source` keeps exposing `br` globally. Other shells are unaffected. Fixes #9392
This commit is contained in:
@@ -139,9 +139,14 @@ let
|
|||||||
# manipulations of the prompt.
|
# manipulations of the prompt.
|
||||||
lib.mkAfter ''
|
lib.mkAfter ''
|
||||||
source ${
|
source ${
|
||||||
pkgs.runCommand "br.${shell}" {
|
pkgs.runCommand "br.${shell}" { nativeBuildInputs = [ cfg.package ]; } (
|
||||||
nativeBuildInputs = [ cfg.package ];
|
if shell == "nushell" then
|
||||||
} "broot --print-shell-function ${shell} > $out"
|
# broot >= 1.51 exports `main` instead of `br`.
|
||||||
|
# Rename back to `br` to keep `source` working.
|
||||||
|
"broot --print-shell-function ${shell} | sed 's/export def --env main/export def --env br/' > $out"
|
||||||
|
else
|
||||||
|
"broot --print-shell-function ${shell} > $out"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
|
|||||||
@@ -3,9 +3,20 @@
|
|||||||
{
|
{
|
||||||
programs.broot = {
|
programs.broot = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
enableBashIntegration = true;
|
||||||
|
enableNushellIntegration = true;
|
||||||
package = (
|
package = (
|
||||||
config.lib.test.mkStubPackage {
|
config.lib.test.mkStubPackage {
|
||||||
name = "broot";
|
name = "broot";
|
||||||
|
# Mimic broot >= 1.51, whose nushell shell function is named `main`.
|
||||||
|
buildScript = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cat > $out/bin/broot <<'EOF'
|
||||||
|
#!/bin/sh
|
||||||
|
echo 'export def --env main ['
|
||||||
|
EOF
|
||||||
|
chmod +x $out/bin/broot
|
||||||
|
'';
|
||||||
extraAttrs = {
|
extraAttrs = {
|
||||||
src = config.lib.test.mkStubPackage {
|
src = config.lib.test.mkStubPackage {
|
||||||
name = "broot-src";
|
name = "broot-src";
|
||||||
@@ -21,8 +32,21 @@
|
|||||||
settings.modal = true;
|
settings.modal = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
programs.bash.enable = true;
|
||||||
|
programs.nushell.enable = true;
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileExists home-files/.config/broot/conf.hjson
|
assertFileExists home-files/.config/broot/conf.hjson
|
||||||
assertFileContains home-files/.config/broot/conf.hjson '"modal": true'
|
assertFileContains home-files/.config/broot/conf.hjson '"modal": true'
|
||||||
|
assertFileRegex home-files/.bashrc 'source /nix/store/.*-br\.bash'
|
||||||
|
assertFileRegex home-files/.config/nushell/config.nu \
|
||||||
|
'source /nix/store/.*-br\.nushell'
|
||||||
|
|
||||||
|
brNushell=$(
|
||||||
|
sed -n 's/^[[:space:]]*source \(\/nix\/store\/.*-br\.nushell\)$/\1/p' \
|
||||||
|
"$(_abs home-files/.config/nushell/config.nu)"
|
||||||
|
)
|
||||||
|
assertFileRegex "$brNushell" 'export def --env br \['
|
||||||
|
assertFileNotRegex "$brNushell" 'export def --env main \['
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user