fix: Correct Nix shell for building correctly

This commit is contained in:
Gabriel Nützi
2023-11-30 22:09:15 +01:00
parent 165f1ccfd1
commit 1883208cf6

132
shell.nix
View File

@@ -1,65 +1,85 @@
{ pkgs ? import <nixpkgs> { } }: {pkgs ? import <nixpkgs> {}}:
with pkgs; with pkgs; let
let
inherit (lib) optional optionals; inherit (lib) optional optionals;
inherit (xorg) libX11 libXrandr libXinerama libXcursor libXi libXext; inherit (xorg) libX11 libXrandr libXinerama libXcursor libXi libXext;
inherit (darwin.apple_sdk.frameworks) Cocoa CoreGraphics Foundation IOKit Kernel OpenGL UniformTypeIdentifiers; inherit (darwin.apple_sdk.frameworks) Cocoa CoreGraphics Foundation IOKit Kernel OpenGL UniformTypeIdentifiers;
harfbuzzWithCoreText = harfbuzz.override { withCoreText = stdenv.isDarwin; }; harfbuzzWithCoreText = harfbuzz.override {withCoreText = stdenv.isDarwin;};
in in
with python3Packages; with python3Packages;
mkShell rec { mkShell rec {
buildInputs = [ buildInputs =
harfbuzzWithCoreText [
ncurses harfbuzzWithCoreText
lcms2 ncurses
xxhash lcms2
] ++ optionals stdenv.isDarwin [ xxhash
Cocoa ]
CoreGraphics ++ optionals stdenv.isDarwin [
Foundation Cocoa
IOKit CoreGraphics
Kernel Foundation
OpenGL IOKit
UniformTypeIdentifiers Kernel
libpng OpenGL
python3 UniformTypeIdentifiers
zlib libpng
] ++ lib.optionals (stdenv.isDarwin && (builtins.hasAttr "UserNotifications" darwin.apple_sdk.frameworks)) [ python3
darwin.apple_sdk.frameworks.UserNotifications zlib
] ++ optionals stdenv.isLinux [ ]
fontconfig libunistring libcanberra libX11 ++ lib.optionals (stdenv.isDarwin && (builtins.hasAttr "UserNotifications" darwin.apple_sdk.frameworks)) [
libXrandr libXinerama libXcursor libxkbcommon libXi libXext darwin.apple_sdk.frameworks.UserNotifications
wayland-protocols wayland dbus ]
] ++ checkInputs; ++ optionals stdenv.isLinux [
fontconfig
libunistring
libcanberra
libX11
libXrandr
libXinerama
libXcursor
libxkbcommon
libXi
libXext
wayland-protocols
wayland
openssl
xxHash
dbus
]
++ checkInputs;
nativeBuildInputs = [ nativeBuildInputs =
ncurses [
pkg-config ncurses
sphinx pkg-config
furo sphinx
sphinx-copybutton furo
sphinxext-opengraph sphinx-copybutton
sphinx-inline-tabs sphinxext-opengraph
] ++ optionals stdenv.isDarwin [ sphinx-inline-tabs
imagemagick ]
libicns # For the png2icns tool. ++ optionals stdenv.isDarwin [
]; imagemagick
libicns # For the png2icns tool.
];
propagatedBuildInputs = optional stdenv.isLinux libGL; propagatedBuildInputs = optional stdenv.isLinux libGL;
checkInputs = [ checkInputs = [
pillow pillow
]; ];
# Causes build failure due to warning when using Clang # Causes build failure due to warning when using Clang
hardeningDisable = [ "strictoverflow" ]; hardeningDisable = ["strictoverflow"];
shellHook = if stdenv.isDarwin then '' shellHook =
export KITTY_NO_LTO= if stdenv.isDarwin
'' else '' then ''
export KITTY_EGL_LIBRARY='${lib.getLib libGL}/lib/libEGL.so.1' export KITTY_NO_LTO=
export KITTY_STARTUP_NOTIFICATION_LIBRARY='${libstartup_notification}/lib/libstartup-notification-1.so' ''
export KITTY_CANBERRA_LIBRARY='${libcanberra}/lib/libcanberra.so' else ''
''; export KITTY_EGL_LIBRARY='${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'
'';
}