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.
|
||||
lib.mkAfter ''
|
||||
source ${
|
||||
pkgs.runCommand "br.${shell}" {
|
||||
nativeBuildInputs = [ cfg.package ];
|
||||
} "broot --print-shell-function ${shell} > $out"
|
||||
pkgs.runCommand "br.${shell}" { nativeBuildInputs = [ cfg.package ]; } (
|
||||
if shell == "nushell" then
|
||||
# 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
|
||||
|
||||
@@ -3,9 +3,20 @@
|
||||
{
|
||||
programs.broot = {
|
||||
enable = true;
|
||||
enableBashIntegration = true;
|
||||
enableNushellIntegration = true;
|
||||
package = (
|
||||
config.lib.test.mkStubPackage {
|
||||
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 = {
|
||||
src = config.lib.test.mkStubPackage {
|
||||
name = "broot-src";
|
||||
@@ -21,8 +32,21 @@
|
||||
settings.modal = true;
|
||||
};
|
||||
|
||||
programs.bash.enable = true;
|
||||
programs.nushell.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/broot/conf.hjson
|
||||
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