Commit ed6956e2 authored by Gaute Ravndal's avatar Gaute Ravndal
Browse files

fish: misc fixes for new default standalone build

Fish no longer sources most files in `$out/share/fish` with 4.2.0, and
instead embeds these files in the fish binary itself:

> The standalone build mode has been made the default. This means that
> the files in $CMAKE_INSTALL_PREFIX/share/fish will not be used
> anymore, except for HTML docs. As a result, future upgrades will no
> longer break running shells if one of fish’s internal helper functions
> has been changed in the updated version. For now, the data files are
> still installed redundantly, to prevent upgrades from breaking
> already-running shells. To reverse this change (which should not be
> necessary), patch out the embed-data feature from cmake/Rust.cmake.
> This option will be removed in future.

This means that any changes to these files now have to be made the input
before the build system tries to embed them.
parent 02f6b314
Loading
Loading
Loading
Loading
+31 −30
Original line number Diff line number Diff line
@@ -240,6 +240,36 @@ stdenv.mkDerivation (finalAttrs: {
  + lib.optionalString (stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isDarwin) ''
    # This test seems to consistently fail on aarch64 and darwin
    rm tests/checks/cd.fish
  ''
  + ''
    substituteInPlace share/functions/grep.fish \
      --replace-fail "command grep" "command ${lib.getExe gnugrep}"

    substituteInPlace share/completions/{sudo.fish,doas.fish} \
      --replace-fail "/usr/local/sbin /sbin /usr/sbin" ""
  ''
  + lib.optionalString usePython ''
    cat > share/functions/__fish_anypython.fish <<EOF
    # localization: skip(private)
    function __fish_anypython
        echo ${python3.interpreter}
        return 0
    end
    EOF
  ''
  + lib.optionalString stdenv.hostPlatform.isLinux ''
    for cur in share/functions/*.fish; do
      substituteInPlace "$cur" \
        --replace-quiet '/usr/bin/getent' '${lib.getExe getent}' \
        --replace-quiet 'awk' '${lib.getExe' gawk "awk"}'
    done
    for cur in share/completions/*.fish; do
      substituteInPlace "$cur" \
        --replace-quiet 'awk' '${lib.getExe' gawk "awk"}'
    done
  ''
  + ''
    tee -a share/__fish_build_paths.fish.in < ${fishPreInitHooks}
  '';

  outputs = [
@@ -338,37 +368,8 @@ stdenv.mkDerivation (finalAttrs: {
    runHook postInstallCheck
  '';

  postInstall = ''
    substituteInPlace "$out/share/fish/functions/grep.fish" \
      --replace-fail "command grep" "command ${lib.getExe gnugrep}"

    substituteInPlace $out/share/fish/completions/{sudo.fish,doas.fish} \
      --replace-fail "/usr/local/sbin /sbin /usr/sbin" ""
  ''
  + lib.optionalString usePython ''
    cat > $out/share/fish/functions/__fish_anypython.fish <<EOF
    function __fish_anypython
        echo ${python3.interpreter}
        return 0
    end
    EOF
  ''
  + lib.optionalString stdenv.hostPlatform.isLinux ''
    for cur in $out/share/fish/functions/*.fish; do
      substituteInPlace "$cur" \
        --replace-quiet '/usr/bin/getent' '${lib.getExe getent}' \
        --replace-quiet 'awk' '${lib.getExe' gawk "awk"}'
    done
    for cur in $out/share/fish/completions/*.fish; do
      substituteInPlace "$cur" \
        --replace-quiet 'awk' '${lib.getExe' gawk "awk"}'
    done
  ''
  + lib.optionalString useOperatingSystemEtc ''
  postInstall = lib.optionalString useOperatingSystemEtc ''
    tee -a $out/etc/fish/config.fish < ${etcConfigAppendix}
  ''
  + ''
    tee -a $out/share/fish/__fish_build_paths.fish < ${fishPreInitHooks}
  '';

  meta = {