todoodoo/default.nix

38 lines
1.4 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
'';
postInstall = ''
mkdir -p $out/share/applications/
cp todoodoo.desktop $out/share/applications/todoodoo.desktop
substituteInPlace $out/share/applications/todoodoo.desktop --replace /usr/bin/todoodoo $out/bin/todoodoo
'';
}