diff --git a/docs/build.rst b/docs/build.rst index 6dc196555..a3a16ce32 100644 --- a/docs/build.rst +++ b/docs/build.rst @@ -78,6 +78,17 @@ you might have to rebuild the app. a self signed certificate, see for example, `here `_. +Build and run from source with Nix +------------------------------------------- + +On NixOS or any other Linux or macOS system with the Nix package manager installed, +execute ``./nix-shell`` to create the correct environment to build kitty or use +``./nix-shell --pure`` instead to eliminate most of the influence of the outside system, +e.g. globally installed packages. ``nix-shell`` will automatically fetch all required +dependencies and make them available in the newly spawned shell. + +Then proceed with ``make`` or ``make app`` according to the platform specific instructions above. + Note for Linux/macOS packagers ---------------------------------- diff --git a/setup.py b/setup.py index d09cad07f..5ef44cb4c 100755 --- a/setup.py +++ b/setup.py @@ -63,11 +63,11 @@ class Options(argparse.Namespace): for_freeze: bool = False libdir_name: str = 'lib' extra_logging: List[str] = [] - link_time_optimization: bool = True + link_time_optimization: bool = 'KITTY_NO_LTO' not in os.environ update_check_interval: float = 24 - egl_library: Optional[str] = None - startup_notification_library: Optional[str] = None - canberra_library: Optional[str] = None + egl_library: Optional[str] = os.getenv('KITTY_EGL_LIBRARY') + startup_notification_library: Optional[str] = os.getenv('KITTY_STARTUP_NOTIFICATION_LIBRARY') + canberra_library: Optional[str] = os.getenv('KITTY_CANBERRA_LIBRARY') class CompileKey(NamedTuple): diff --git a/shell.nix b/shell.nix new file mode 100644 index 000000000..fe02bca02 --- /dev/null +++ b/shell.nix @@ -0,0 +1,55 @@ +{ pkgs ? import { } }: +with pkgs; + +let + inherit (lib) optional optionals; + inherit (xorg) libX11 libXrandr libXinerama libXcursor libXi libXext; + inherit (darwin.apple_sdk.frameworks) Cocoa CoreGraphics Foundation IOKit Kernel OpenGL; + harfbuzzWithCoreText = harfbuzz.override { withCoreText = stdenv.isDarwin; }; +in +mkShell rec { + buildInputs = [ + harfbuzzWithCoreText + ncurses + lcms2 + ] ++ optionals stdenv.isDarwin [ + Cocoa + CoreGraphics + Foundation + IOKit + Kernel + OpenGL + libpng + python3 + zlib + ] ++ optionals stdenv.isLinux [ + fontconfig libunistring libcanberra libX11 + libXrandr libXinerama libXcursor libxkbcommon libXi libXext + wayland-protocols wayland dbus + ] ++ checkInputs; + + nativeBuildInputs = [ + pkgconfig python3Packages.sphinx ncurses + ] ++ optionals stdenv.isDarwin [ + imagemagick + libicns # For the png2icns tool. + installShellFiles + ]; + + propagatedBuildInputs = optional stdenv.isLinux libGL; + + checkInputs = [ + python3Packages.pillow + ]; + + # Causes build failure due to warning when using Clang + hardeningDisable = [ "strictoverflow" ]; + + shellHook = if stdenv.isDarwin then '' + export KITTY_NO_LTO= + '' else '' + export KITTY_EGL_LIBRARY='${stdenv.lib.getLib libGL}/lib/libEGL.so.1' + export KITTY_STARTUP_NOTIFICATION_LIBRARY='${libstartup_notification}/lib/libstartup-notification-1.so' + export KITTY_CANBERRA_LIBRARY='${libcanberra}/lib/libcanberra.so' + ''; +}