48 lines
1.7 KiB
Nix
48 lines
1.7 KiB
Nix
{
|
|
pkgs ? import <nixpkgs> { },
|
|
}:
|
|
let
|
|
manifest = (pkgs.lib.importTOML ./Cargo.toml).package;
|
|
packages = with pkgs; [
|
|
pkg-config
|
|
libGLU
|
|
libGL
|
|
libxkbcommon
|
|
xorg.libX11
|
|
xorg.libXcursor
|
|
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
|
|
patchelf --add-needed libX11.so target/${pkgs.stdenv.targetPlatform.config}/release/ants
|
|
patchelf --add-needed libXcursor.so target/${pkgs.stdenv.targetPlatform.config}/release/ants
|
|
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
|
|
'';
|
|
}
|