I am trying to package a CAD system (BricsCAD) for Nix, which has many of its dependencies bundled in the download. I found as many as I could using nix-locate, and included those in the build inputs, but there are still a lot of libraries that aren’t available in nixpkgs from what I can tell.
I am trying to use autopatchelf as described on the NixOS Wiki. I am copying all of the included libraries to $out/lib during the install phase, they have execute permissions already, and it builds without any error. However, when I try to run the binary I get the error:
zsh: no such file or directory: ./result/bin/bricscad
And running ldd on the binary shows most of the dependencies are not found.
From my understanding, autopatchelf expects these dependencies from other packages in nixpkgs to be in $out/lib for the respective packages, but does not seem to find them when they are part of the package I am trying to build. I have tried a few other things but haven’t found anything that works yet.
Do I need to do something with makeWrapper, or are there other flags I can pass to autopatchelf to have it use the provided libraries?
I feel like I’m missing something obvious, I’m pretty new to Nix and I’m not a programmer, so I don’t really have the best understanding of what is really going on.
My flake.nix is below:
{
description = "BricsCAD";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
};
outputs = { self, nixpkgs }: {
defaultPackage.x86_64-linux =
with import nixpkgs { system = "x86_64-linux"; };
stdenv.mkDerivation rec {
pname = "bricscad";
version = "24.1.07";
src = ./BricsCAD-V${version}-1-en_US-amd64.deb;
dontFixup = true;
nativeBuildInputs = [
pkgs.autoPatchelfHook
];
buildInputs = [
pkgs.remarkable2-toolchain
pkgs.opendylan_bin
pkgs.xercesc
pkgs.gtk3
pkgs.wxGTK31
pkgs.qt6.full
pkgs.webkitgtk
pkgs.dpkg
];
sourceRoot = ".";
installPhase = ''
runHook preInstall
mkdir -p $out
dpkg -x $src $out
chmod 755 $out
mv $out/usr/* $out
rm -r $out/usr
mkdir -p $out/lib
cp $out/opt/bricsys/bricscad/v24/*.so $out/lib
cp $out/opt/bricsys/bricscad/v24/*.so.* $out/lib
cp $out/opt/bricsys/bricscad/v24/*.tx $out/lib
ln -s $out/opt/bricsys/bricscad/v24/bricscad $out/bin/bricscad
runHook postInstall
'';
meta = with lib; {
description = "BricsCAD";
platforms = platforms.linux;
};
};
};
}