Skip to content

Commit

Permalink
fish: 3.7.1 -> 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
r-vdp committed Dec 21, 2024
1 parent db8c665 commit 955059f
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 24 deletions.
66 changes: 42 additions & 24 deletions pkgs/shells/fish/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
fetchpatch,
coreutils,
which,
glibcLocales,
gnused,
gnugrep,
groff,
Expand All @@ -20,6 +21,10 @@
fishPlugins,
procps,

cargo,
rustc,
rustPlatform,

# used to generate autocompletions from manpages and for configuration editing in the browser
usePython ? true,

Expand Down Expand Up @@ -143,7 +148,7 @@ let

fish = stdenv.mkDerivation rec {
pname = "fish";
version = "3.7.1";
version = "4.0b1";

src = fetchurl {
# There are differences between the release tarball and the tarball GitHub
Expand All @@ -153,10 +158,17 @@ let
# --version`), as well as the local documentation for all builtins (and
# maybe other things).
url = "https://github.com/fish-shell/fish-shell/releases/download/${version}/${pname}-${version}.tar.xz";
hash = "sha256-YUyfVkPNB5nfOROV+mu8NklCe7g5cizjsRTTu8GjslA=";
hash = "sha256-U0M04Q+FciIU6dr/gqV8w1ASNVI/FvjxMcI0Tk7Jjac=";
};

cargoDeps = rustPlatform.fetchCargoVendor {
inherit src;
hash = "sha256-jTVZKzX/Uy2RtyMbeQmatLLrOO+5S5jXrYKMGXNMcV4=";
};

patches = [
./disable_suid_test.patch

# We don’t want to run `/usr/libexec/path_helper` on nix-darwin,
# as it pulls in paths not tracked in the system configuration
# and messes up the order of `$PATH`. Upstream are unfortunately
Expand All @@ -173,14 +185,13 @@ let
# Fix FHS paths in tests
postPatch =
''
# src/fish_tests.cpp
sed -i 's|/bin/ls|${coreutils}/bin/ls|' src/fish_tests.cpp
sed -i 's|is_potential_path(L"/usr"|is_potential_path(L"/nix"|' src/fish_tests.cpp
sed -i 's|L"/bin/echo"|L"${coreutils}/bin/echo"|' src/fish_tests.cpp
sed -i 's|L"/bin/c"|L"${coreutils}/bin/c"|' src/fish_tests.cpp
sed -i 's|L"/bin/ca"|L"${coreutils}/bin/ca"|' src/fish_tests.cpp
# disable flakey test
sed -i '/{TEST_GROUP("history_races"), history_tests_t::test_history_races},/d' src/fish_tests.cpp
sed -i 's|"/bin/ls"|"${lib.getExe' coreutils "ls"}"|' src/builtins/tests/test_tests.rs
sed -i 's|"/bin/echo"|"${lib.getExe' coreutils "echo"}"|' src/tests/highlight.rs
# TODO: are the next two correct??
sed -i 's|"/bin/c"|"${lib.getExe' coreutils "c"}"|' src/tests/highlight.rs
sed -i 's|"/bin/ca"|"${lib.getExe' coreutils "ca"}"|' src/tests/highlight.rs
sed -i 's|/usr|/build|' src/tests/highlight.rs
# tests/checks/cd.fish
sed -i 's|/bin/pwd|${coreutils}/bin/pwd|' tests/checks/cd.fish
Expand All @@ -202,16 +213,16 @@ let
sed -i 's|/bin/ls|${coreutils}/bin/ls|' tests/checks/complete.fish
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
# Tests use pkill/pgrep which are currently not built on Darwin
# See https://github.com/NixOS/nixpkgs/pull/103180
rm tests/pexpects/exit.py
rm tests/pexpects/job_summary.py
rm tests/pexpects/signals.py
# pexpect tests are flaky in general
# See https://github.com/fish-shell/fish-shell/issues/8789
rm tests/pexpects/bind.py
''
# # Tests use pkill/pgrep which are currently not built on Darwin
# # See https://github.com/NixOS/nixpkgs/pull/103180
# rm tests/pexpects/exit.py
# rm tests/pexpects/job_summary.py
# rm tests/pexpects/signals.py
# # pexpect tests are flaky in general
# # See https://github.com/fish-shell/fish-shell/issues/8789
# rm tests/pexpects/bind.py
# ''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
# pexpect tests are flaky on aarch64-linux (also x86_64-linux)
# See https://github.com/fish-shell/fish-shell/issues/8789
Expand All @@ -226,10 +237,13 @@ let
nativeBuildInputs = [
cmake
gettext

cargo
rustc
rustPlatform.cargoSetupHook
];

buildInputs = [
ncurses
libiconv
pcre2
];
Expand Down Expand Up @@ -273,12 +287,18 @@ let

nativeCheckInputs = [
coreutils
glibcLocales
(python3.withPackages (ps: [ ps.pexpect ]))
procps
];

checkPhase = ''
runHook preCheck
export TERMINFO="${ncurses}/share/terminfo"
make test
runHook postCheck
'';

postInstall =
Expand All @@ -295,8 +315,6 @@ let
"$out/share/fish/functions/prompt_pwd.fish"
sed -i "s|nroff|${groff}/bin/nroff|" \
"$out/share/fish/functions/__fish_print_help.fish"
sed -e "s|clear;|${lib.getBin ncurses}/bin/clear;|" \
-i "$out/share/fish/functions/fish_default_key_bindings.fish"
sed -i "s|/usr/local/sbin /sbin /usr/sbin||" \
$out/share/fish/completions/{sudo.fish,doas.fish}
sed -e "s| awk | ${gawk}/bin/awk |" \
Expand Down Expand Up @@ -366,7 +384,7 @@ let
# if we don't set `delete=False`, the file will get cleaned up
# automatically (leading the test to fail because there's no
# tempfile to check)
${lib.getExe gnused} -e 's@, mode="w"@, mode="w", delete=False@' -i webconfig.py
${lib.getExe gnused} -e 's@delete=True,@delete=False,@' -i webconfig.py
# we delete everything after the fileurl is assigned
${lib.getExe gnused} -e '/fileurl =/q' -i webconfig.py
Expand Down
17 changes: 17 additions & 0 deletions pkgs/shells/fish/disable_suid_test.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/tests/checks/path.fish b/tests/checks/path.fish
index 62812571a..b0eebcd91 100644
--- a/tests/checks/path.fish
+++ b/tests/checks/path.fish
@@ -117,12 +117,6 @@ path filter --type file,dir --perm exec,write bin/fish .
# So it passes.
# CHECK: .

-mkdir -p sbin
-touch sbin/setuid-exe sbin/setgid-exe
-chmod u+s,a+x sbin/setuid-exe
-path filter --perm suid sbin/*
-# CHECK: sbin/setuid-exe
-
# On at least FreeBSD on our CI this fails with "permission denied".
# So we can't test it, and we fake the output instead.
if chmod g+s,a+x sbin/setgid-exe 2>/dev/null

0 comments on commit 955059f

Please sign in to comment.