2023-09-15 20:06:30 +02:00
|
|
|
{
|
|
|
|
description = "tomato flake";
|
|
|
|
# bc flakes and git submodules dont really like each other, you need to
|
|
|
|
# append '.?submodules=1' to the nix commands.
|
|
|
|
|
|
|
|
inputs = {
|
2024-06-12 16:40:07 +02:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/release-24.05";
|
2023-09-16 23:54:51 +02:00
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
2024-04-14 12:03:58 +02:00
|
|
|
nlohmann-json = {
|
|
|
|
url = "github:nlohmann/json/v3.11.3"; # TODO: read version from file
|
|
|
|
flake = false;
|
|
|
|
};
|
2024-04-15 18:12:17 +02:00
|
|
|
sdl3 = {
|
2024-11-15 23:17:32 +01:00
|
|
|
url = "github:libsdl-org/SDL/f8468d580d903e106640800034a4721aca24264c"; # keep in sync this cmake
|
2024-04-15 18:12:17 +02:00
|
|
|
flake = false;
|
|
|
|
};
|
2024-04-15 15:43:45 +02:00
|
|
|
sdl3_image = {
|
2024-10-05 15:44:29 +02:00
|
|
|
url = "github:libsdl-org/SDL_image/6f4584340b9b78542d11bf0232a1a0862de1f0a9";
|
2024-04-15 15:43:45 +02:00
|
|
|
flake = false;
|
|
|
|
};
|
2023-09-15 20:06:30 +02:00
|
|
|
};
|
|
|
|
|
2024-04-15 15:43:45 +02:00
|
|
|
outputs = { self, nixpkgs, flake-utils, nlohmann-json, sdl3, sdl3_image }:
|
2023-09-16 23:54:51 +02:00
|
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { inherit system; };
|
2024-02-25 18:45:56 +01:00
|
|
|
stdenv = (pkgs.stdenvAdapters.keepDebugInfo pkgs.stdenv);
|
2024-06-09 09:11:39 +02:00
|
|
|
#stdenv = (pkgs.stdenvAdapters.withCFlags [ "-march=x86-64-v3" ] (pkgs.stdenvAdapters.keepDebugInfo pkgs.stdenv));
|
2023-09-16 23:54:51 +02:00
|
|
|
in {
|
2024-02-25 18:45:56 +01:00
|
|
|
#packages.default = pkgs.stdenv.mkDerivation {
|
|
|
|
packages.default = stdenv.mkDerivation {
|
2023-09-16 23:54:51 +02:00
|
|
|
pname = "tomato";
|
|
|
|
version = "0.0.0";
|
2023-09-15 20:06:30 +02:00
|
|
|
|
2023-09-16 23:54:51 +02:00
|
|
|
src = ./.;
|
2024-02-25 18:45:56 +01:00
|
|
|
submodules = 1; # does nothing
|
2023-09-15 20:06:30 +02:00
|
|
|
|
2023-09-16 23:54:51 +02:00
|
|
|
nativeBuildInputs = with pkgs; [
|
|
|
|
cmake
|
|
|
|
ninja
|
|
|
|
pkg-config
|
|
|
|
patchelf
|
|
|
|
];
|
2023-09-15 20:06:30 +02:00
|
|
|
|
2023-09-16 23:54:51 +02:00
|
|
|
# for some reason, buildInputs performs some magic an converts them to build dependencies, not runtime dependencies
|
|
|
|
# also, non static dependencies (?? how to ensure ??)
|
|
|
|
dlopenBuildInputs = with pkgs; [
|
2023-09-29 18:15:18 +02:00
|
|
|
dbus
|
|
|
|
|
2023-09-16 23:54:51 +02:00
|
|
|
xorg.libX11
|
|
|
|
xorg.libXext
|
|
|
|
xorg.xorgproto
|
2023-09-29 18:15:18 +02:00
|
|
|
libxkbcommon
|
2023-09-16 23:54:51 +02:00
|
|
|
xorg.libICE
|
|
|
|
xorg.libXi
|
|
|
|
xorg.libXScrnSaver
|
|
|
|
xorg.libXcursor
|
|
|
|
xorg.libXinerama
|
|
|
|
xorg.libXrandr
|
|
|
|
xorg.libXxf86vm
|
2023-09-29 18:15:18 +02:00
|
|
|
|
2023-09-16 23:54:51 +02:00
|
|
|
libGL
|
2023-09-29 18:15:18 +02:00
|
|
|
|
|
|
|
pipewire
|
2024-04-15 15:43:45 +02:00
|
|
|
|
|
|
|
# sdl3_image:
|
|
|
|
libpng
|
|
|
|
libjpeg
|
|
|
|
libjxl
|
2024-04-16 10:30:13 +02:00
|
|
|
libavif
|
2024-04-15 15:43:45 +02:00
|
|
|
#libwebp # still using our own loader
|
2023-09-16 23:54:51 +02:00
|
|
|
];
|
2023-09-15 20:06:30 +02:00
|
|
|
|
2023-09-16 23:54:51 +02:00
|
|
|
buildInputs = with pkgs; [
|
|
|
|
#(libsodium.override { stdenv = pkgs.pkgsStatic.stdenv; })
|
|
|
|
#pkgsStatic.libsodium
|
|
|
|
libsodium
|
2024-07-16 10:37:19 +02:00
|
|
|
libopus
|
|
|
|
libvpx
|
2023-09-16 23:54:51 +02:00
|
|
|
] ++ self.packages.${system}.default.dlopenBuildInputs;
|
2023-09-15 20:06:30 +02:00
|
|
|
|
2024-01-14 21:48:41 +01:00
|
|
|
cmakeFlags = [
|
2024-10-01 18:46:52 +02:00
|
|
|
"-DTOMATO_TOX_AV=ON"
|
2024-03-16 16:43:45 +01:00
|
|
|
"-DTOMATO_ASAN=OFF"
|
|
|
|
"-DCMAKE_BUILD_TYPE=RelWithDebInfo"
|
2024-07-16 09:59:22 +02:00
|
|
|
#"-DCMAKE_BUILD_TYPE=Debug"
|
|
|
|
#"-DCMAKE_C_FLAGS:STRING=-Og"
|
|
|
|
#"-DCMAKE_CXX_FLAGS:STRING=-Og"
|
2024-02-17 22:52:55 +01:00
|
|
|
|
2024-04-14 12:03:58 +02:00
|
|
|
"-DFETCHCONTENT_SOURCE_DIR_JSON=${nlohmann-json}" # we care about the version
|
2024-04-14 14:32:31 +02:00
|
|
|
# TODO: use package instead
|
2024-04-14 12:03:58 +02:00
|
|
|
"-DFETCHCONTENT_SOURCE_DIR_ZSTD=${pkgs.zstd.src}" # we dont care about the version (we use 1.4.x features)
|
2024-04-15 01:10:15 +02:00
|
|
|
"-DFETCHCONTENT_SOURCE_DIR_LIBWEBP=${pkgs.libwebp.src}"
|
2024-04-15 18:12:17 +02:00
|
|
|
"-DFETCHCONTENT_SOURCE_DIR_SDL3=${sdl3}"
|
2024-04-15 15:43:45 +02:00
|
|
|
"-DFETCHCONTENT_SOURCE_DIR_SDL3_IMAGE=${sdl3_image}"
|
2024-09-19 09:22:56 +02:00
|
|
|
"-DSDLIMAGE_JXL=ON"
|
2024-01-14 21:48:41 +01:00
|
|
|
];
|
|
|
|
|
2023-09-16 23:54:51 +02:00
|
|
|
# TODO: replace with install command
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
mv bin/tomato $out/bin
|
2023-09-15 20:06:30 +02:00
|
|
|
'';
|
|
|
|
|
2024-02-25 18:45:56 +01:00
|
|
|
dontStrip = true; # does nothing
|
2024-01-14 21:48:41 +01:00
|
|
|
|
2023-09-16 23:54:51 +02:00
|
|
|
# copied from nixpkgs's SDL2 default.nix
|
|
|
|
# SDL is weird in that instead of just dynamically linking with
|
|
|
|
# libraries when you `--enable-*` (or when `configure` finds) them
|
|
|
|
# it `dlopen`s them at runtime. In principle, this means it can
|
|
|
|
# ignore any missing optional dependencies like alsa, pulseaudio,
|
|
|
|
# some x11 libs, wayland, etc if they are missing on the system
|
|
|
|
# and/or work with wide array of versions of said libraries. In
|
|
|
|
# nixpkgs, however, we don't need any of that. Moreover, since we
|
|
|
|
# don't have a global ld-cache we have to stuff all the propagated
|
|
|
|
# libraries into rpath by hand or else some applications that use
|
|
|
|
# SDL API that requires said libraries will fail to start.
|
|
|
|
#
|
|
|
|
# You can grep SDL sources with `grep -rE 'SDL_(NAME|.*_SYM)'` to
|
|
|
|
# list the symbols used in this way.
|
|
|
|
# TODO: only patch if building FOR nix (like not for when static building)
|
|
|
|
postFixup =
|
|
|
|
let
|
|
|
|
#rpath = lib.makeLibraryPath (dlopenPropagatedBuildInputs ++ dlopenBuildInputs);
|
|
|
|
rpath = nixpkgs.lib.makeLibraryPath (self.packages.${system}.default.dlopenBuildInputs);
|
|
|
|
in
|
|
|
|
nixpkgs.lib.optionalString (pkgs.stdenv.hostPlatform.extensions.sharedLibrary == ".so") ''
|
|
|
|
patchelf --set-rpath "$(patchelf --print-rpath $out/bin/tomato):${rpath}" "$out/bin/tomato"
|
|
|
|
'';
|
|
|
|
};
|
2023-09-15 20:06:30 +02:00
|
|
|
|
2024-02-25 18:45:56 +01:00
|
|
|
#packages.debug = pkgs.enableDebugging self.packages.${system}.default;
|
|
|
|
|
2023-09-16 23:54:51 +02:00
|
|
|
devShells.${system}.default = pkgs.mkShell {
|
|
|
|
#inputsFrom = with pkgs; [ SDL2 ];
|
|
|
|
buildInputs = [ self.packages.${system}.default ]; # this makes a prebuild tomato available in the shell, do we want this?
|
2023-09-15 20:06:30 +02:00
|
|
|
|
2023-09-16 23:54:51 +02:00
|
|
|
packages = with pkgs; [
|
|
|
|
cmake
|
|
|
|
pkg-config
|
|
|
|
];
|
2023-09-15 20:06:30 +02:00
|
|
|
|
2024-08-10 10:53:57 +02:00
|
|
|
shellHook = ''
|
|
|
|
echo hello to tomato dev shell!
|
2024-12-01 12:52:39 +01:00
|
|
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/run/opengl-driver/lib
|
2024-08-10 10:53:57 +02:00
|
|
|
'';
|
2023-09-16 23:54:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
apps.default = {
|
|
|
|
type = "app";
|
|
|
|
program = "${self.packages.${system}.default}/bin/tomato";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
2023-09-15 20:06:30 +02:00
|
|
|
}
|