todoodoo/default.nix
2024-02-05 21:27:19 +01:00

32 lines
1.2 KiB
Nix

{pkgs ? import <nixpkgs> {}}: let
manifest = (pkgs.lib.importTOML ./Cargo.toml).package;
packages = with pkgs; [
pkg-config
libGLU
libGL
libxkbcommon
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 = ''
patchelf --add-needed libxkbcommon.so target/x86_64-unknown-linux-gnu/release/todoodoo
patchelf --add-needed libwayland-client.so target/x86_64-unknown-linux-gnu/release/todoodoo
patchelf --add-needed libGLU.so target/x86_64-unknown-linux-gnu/release/todoodoo
patchelf --add-needed libEGL.so target/x86_64-unknown-linux-gnu/release/todoodoo
old_rpath=$(patchelf --print-rpath target/x86_64-unknown-linux-gnu/release/todoodoo)
if [[ -z "$old_rpath" ]]; then
patchelf --set-rpath "${pkgs.lib.makeLibraryPath packages}" target/x86_64-unknown-linux-gnu/release/todoodoo
else
patchelf --set-rpath "${pkgs.lib.makeLibraryPath packages}:$old_rpath" target/x86_64-unknown-linux-gnu/release/todoodoo
fi
'';
}