clear env, dont inherit nix wrapper env
This commit is contained in:
@@ -108,6 +108,7 @@
|
|||||||
done
|
done
|
||||||
|
|
||||||
makeWrapper "${pkgs.jdk25}/bin/java" "$out/bin/jprototerm" \
|
makeWrapper "${pkgs.jdk25}/bin/java" "$out/bin/jprototerm" \
|
||||||
|
--run 'export JPROTOTERM_HOST_LD_LIBRARY_PATH="''${LD_LIBRARY_PATH:-}"' \
|
||||||
--add-flags "--enable-native-access=ALL-UNNAMED,javafx.graphics" \
|
--add-flags "--enable-native-access=ALL-UNNAMED,javafx.graphics" \
|
||||||
--add-flags "--module-path $out/share/jprototerm/javafx" \
|
--add-flags "--module-path $out/share/jprototerm/javafx" \
|
||||||
--add-flags "--add-modules javafx.controls,javafx.fxml" \
|
--add-flags "--add-modules javafx.controls,javafx.fxml" \
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public final class ShellSession implements AutoCloseable {
|
|||||||
Map<String, String> environment = new HashMap<>(System.getenv());
|
Map<String, String> environment = new HashMap<>(System.getenv());
|
||||||
environment.put("TERM", "xterm-kitty");
|
environment.put("TERM", "xterm-kitty");
|
||||||
environment.put("COLORTERM", "truecolor");
|
environment.put("COLORTERM", "truecolor");
|
||||||
|
sanitizeWrapperEnvironment(environment);
|
||||||
environment.putAll(envOverride);
|
environment.putAll(envOverride);
|
||||||
|
|
||||||
LinuxPty pty = LinuxPty.spawn(
|
LinuxPty pty = LinuxPty.spawn(
|
||||||
@@ -42,6 +43,30 @@ public final class ShellSession implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Strips the variables injected by the Nix launcher wrapper from the shell's
|
||||||
|
* environment so they do not leak into terminal subprocesses.
|
||||||
|
*
|
||||||
|
* <p>jprototerm is launched from a Nix wrapper that prepends Nix store paths to
|
||||||
|
* {@code LD_LIBRARY_PATH} (and adds a GL shim) so the bundled JavaFX/ghostty natives
|
||||||
|
* resolve. If the shell inherited that path, host programs run inside the terminal
|
||||||
|
* (e.g. {@code flatpak}, {@code pdftoppm}) would load the Nix copies of libraries such
|
||||||
|
* as freetype/fontconfig/glib, which in turn drag in the Nix glibc through their
|
||||||
|
* RUNPATHs and clash with the host {@code libc.so.6}. We restore the user's original
|
||||||
|
* {@code LD_LIBRARY_PATH}, captured by the wrapper before it prepended anything.
|
||||||
|
*/
|
||||||
|
private static void sanitizeWrapperEnvironment(Map<String, String> environment) {
|
||||||
|
String hostLibraryPath = environment.remove("JPROTOTERM_HOST_LD_LIBRARY_PATH");
|
||||||
|
if (hostLibraryPath == null || hostLibraryPath.isEmpty()) {
|
||||||
|
environment.remove("LD_LIBRARY_PATH");
|
||||||
|
} else {
|
||||||
|
environment.put("LD_LIBRARY_PATH", hostLibraryPath);
|
||||||
|
}
|
||||||
|
// These are jprototerm's own runtime settings, not the user's shell environment.
|
||||||
|
environment.remove("GDK_BACKEND");
|
||||||
|
environment.remove("JLIBGHOSTTY_LIBRARY");
|
||||||
|
}
|
||||||
|
|
||||||
public void startReading(TerminalPane pane) {
|
public void startReading(TerminalPane pane) {
|
||||||
reader.submit(() -> readOutput(pane));
|
reader.submit(() -> readOutput(pane));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user