I’m writing a default.nix to run the flashprint, which is a slicer for flashforge 3d printers.
The software itself is published in .deb
format, and I’m able to run it manually by
nix-shell -p dpkg steam-run-native libsForQt5.full
dpkg -x software.deb ./forgeprint
export LD_LIBRARY_PATH=<qt5 lib dir>/lib ##<- this line is necessary, but I don't know why?, but this is not the problem. I just put this variable in my default.nix in the makeWrapper's argument list
steam-run ./flageforge/usr/share/FlashPrint5/FlashPrint
The software can be launched and works fine!
Then I try to wrap it with a default.nix and put it into my /etc/nixos so that I can nix-shell -p forgeprint
.
But it did not work.
The default.nix
is pasted in the very end of this post. But first let me describe my difficulty:
If I run
nix-shell -p forgeprint
It complains
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
Could not find the Qt platform plugin “xcb” in “”
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
I have to run
nix-shell -p flashprint libsForQt5.full
flashprint
then it works.
I have already put libsForQt5.full in the default.nix. So I do not understand why itself cannot find the files of libsForQt5.full?
Following is the full content of the forgeprint’s default.nix
{ lib, stdenv
, makeWrapper
, fetchurl
, dpkg
, libsForQt5
, libxcb
, steam-run-native
}:
stdenv.mkDerivation rec {
pname = "flashprint";
version = "5.3.4";
src = fetchurl {
url = "https://en.fss.flashforge.com/10000/software/381b6e81ee43825019157b657839885b.deb";
sha256 = "1dwpnq6kfqh31pi3igr38j2aghbwg392krx302wz4j0irpihypzn";
};
unpackCmd = "dpkg -x $src .";
sourceRoot = ".";
nativeBuildInputs = [ dpkg makeWrapper libsForQt5.full ];
meta = with lib; {
description = "FlashPrint";
homepage = "https://www.flashforge.com/";
platforms = [ "x86_64-linux" ];
hydraPlatforms = [];
license = licenses.unfreeRedistributable;
maintainers = with maintainers; [ jhgu ];
};
buildInputs = [
dpkg
libsForQt5.full
steam-run-native
];
dontPatchELF = true;
# wpsoffice uses `/build` in its own build system making nix things there
# references to nix own build directory
installPhase = ''
mkdir -p $out/bin;
cp -r etc $out;
cp -r usr $out;
makeWrapper ${steam-run-native}/bin/steam-run $out/bin/flashprint \
--add-flags $out/usr/share/FlashPrint5/FlashPrint \
--argv0 FlashPrint \
--prefix LD_LIBRARY_PATH : ${libsForQt5.full}/lib
'';
#whether comment out following lines does not affect the result
#dontWrapQtApps = true;
#dontWrapGApps = true;
}