outfly/build/nix/build.nix

70 lines
1.5 KiB
Nix
Raw Permalink Normal View History

{ lib
, self ? null
, buildType ? "release"
, platform ? "linux"
, enableWayland ? true
, enableXorg ? true
, enableOpenGL ? true
, enableVulkan ? true
, rustPlatform
, makeDesktopItem
, pkg-config
, libxkbcommon
, alsa-lib
, libGL
, vulkan-loader
, wayland
, libXrandr
, libXcursor
, libX11
, libXi
, ...
}:
assert (platform == "linux" ) -> (enableWayland || enableXorg);
assert (platform == "linux" ) -> (enableVulkan || enableOpenGL);
rustPlatform.buildRustPackage rec {
name = "outfly";
inherit buildType;
src = ./../..;
version = if (self ? rev) then self.rev else "dirty";
buildNoDefaultFeatures = true;
buildFeatures = [ "embed_assets" ] ++ lib.optionals enableXorg [ "x11" ]
++ lib.optionals enableWayland [ "wayland" ];
runtimeInputs = [ libxkbcommon ]
++ lib.optionals enableOpenGL [ libGL ]
++ lib.optionals enableXorg [ libXrandr libX11 ]
++ lib.optionals enableVulkan [ vulkan-loader ];
buildInputs = [ alsa-lib.dev libXcursor libXi ]
++ lib.optionals enableWayland [ wayland ];
nativeBuildInputs = [ pkg-config ];
doCheck = false;
postFixup = ''
patchelf $out/bin/outfly \
--add-rpath ${lib.makeLibraryPath runtimeInputs}
'';
postPatch = ''
find ../cargo-vendor-dir -name Cargo.toml -exec sed -i 's/^workspace = true//' {} +
'';
cargoLock = { lockFile = ./../../Cargo.lock; };
desktopItems = [
(makeDesktopItem {
name = "outfly";
exec = "outfly";
desktopName = "OutFly";
categories = [ "Game" ];
})
];
}