ants/default.nix

49 lines
1.7 KiB
Nix
Raw Normal View History

2024-04-09 09:54:45 +02:00
{
pkgs ? import <nixpkgs> { },
}:
let
manifest = (pkgs.lib.importTOML ./Cargo.toml).package;
packages = with pkgs; [
pkg-config
libGLU
libGL
libxkbcommon
2024-04-09 15:22:17 +02:00
xorg.libX11
xorg.libXcursor
2024-04-09 09:54:45 +02:00
wayland
];
in
pkgs.rustPlatform.buildRustPackage {
pname = manifest.name;
version = manifest.version;
cargoLock.lockFile = ./Cargo.lock;
src = pkgs.lib.cleanSource ./.;
meta = {
description = manifest.description ? null;
};
postBuild = ''
ls -la .
ls -la ./target
patchelf --add-needed libxkbcommon.so target/${pkgs.stdenv.targetPlatform.config}/release/ants
patchelf --add-needed libwayland-client.so target/${pkgs.stdenv.targetPlatform.config}/release/ants
patchelf --add-needed libGLU.so target/${pkgs.stdenv.targetPlatform.config}/release/ants
patchelf --add-needed libEGL.so target/${pkgs.stdenv.targetPlatform.config}/release/ants
2024-04-09 15:22:17 +02:00
patchelf --add-needed libX11.so target/${pkgs.stdenv.targetPlatform.config}/release/ants
patchelf --add-needed libXcursor.so target/${pkgs.stdenv.targetPlatform.config}/release/ants
2024-04-09 09:54:45 +02:00
old_rpath=$(patchelf --print-rpath target/${pkgs.stdenv.targetPlatform.config}/release/ants)
if [[ -z "$old_rpath" ]]; then
patchelf --set-rpath "${pkgs.lib.makeLibraryPath packages}" target/${pkgs.stdenv.targetPlatform.config}/release/ants
else
patchelf --set-rpath "${pkgs.lib.makeLibraryPath packages}:$old_rpath" target/${pkgs.stdenv.targetPlatform.config}/release/ants
fi
'';
postInstall = ''
mkdir -p $out/share/applications/
cp ants.desktop $out/share/applications/ants.desktop
substituteInPlace $out/share/applications/ants.desktop --replace /usr/bin/ants $out/bin/ants
'';
}