Closed Bitbitti closed 2 months ago
Could you include custom package you are trying to build.
Thank you for your quick response. Here is the custom package derivation I'm trying to build, along with the preparation script:
{ stdenv
, lib
, fetchurl
, dpkg
, makeWrapper
, autoPatchelfHook
, cups
, libusb1
, libtool
, glib
, glibc
, gnused
, gnutar
, gzip
, dos2unix
}:
stdenv.mkDerivation rec {
pname = "canon-cups-ufr2-custom";
version = "5.70";
src = fetchurl {
url = "https://gdlp01.c-wss.com/gds/4/0100010264/01/linux-UFRII-drv-v370-uken-07.tar.gz";
sha256 = "01nxpg3h1c64p5skxv904fg5c4sblmif486vkij2v62wwn6l65pz";
};
nativeBuildInputs = [ dpkg makeWrapper autoPatchelfHook gnutar gzip gnused dos2unix ];
buildInputs = [ cups libusb1 libtool glib glibc ];
unpackPhase = ''
runHook preUnpack
${gnutar}/bin/tar xzf $src
find . -type f -exec ${dos2unix}/bin/dos2unix {} +
cd linux-UFRII-drv-v370-uken
${gnutar}/bin/tar xzf Sources/cndrvcups-lb-3.70-1.tar.gz
find . -type f -exec ${dos2unix}/bin/dos2unix {} +
runHook postUnpack
'';
buildPhase = ''
runHook preBuild
find . -type f -exec ${dos2unix}/bin/dos2unix {} +
echo "No build required"
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/lib/cups/filter
mkdir -p $out/share/cups/model
cp ${./pstoufr2cpca} $out/lib/cups/filter/
chmod +x $out/lib/cups/filter/pstoufr2cpca
${dos2unix}/bin/dos2unix $out/lib/cups/filter/pstoufr2cpca
PPD_PATH=$(find . -name "*C5870*.ppd")
if [ -n "$PPD_PATH" ]; then
cp $PPD_PATH $out/share/cups/model/
find $out/share/cups/model -type f -exec ${dos2unix}/bin/dos2unix {} +
else
echo "Error: PPD file not found"
exit 1
fi
if [ -d "libs" ]; then
cp -r libs/* $out/lib/
elif [ -d "cndrvcups-lb-3.70/libs" ]; then
cp -r cndrvcups-lb-3.70/libs/* $out/lib/
else
echo "Error: Library directory not found"
exit 1
fi
find $out -type f -exec ${dos2unix}/bin/dos2unix {} +
runHook postInstall
'';
postFixup = ''
wrapProgram $out/lib/cups/filter/pstoufr2cpca \
--prefix LD_LIBRARY_PATH : $out/lib
'';
meta = with lib; {
description = "Canon UFR II / UFRII LT Printer Driver for Linux";
homepage = "https://www.canon.it/support/consumer_products/products/fax__multifunctionals/laser/imagerunner_series/imagerunner-dx-c5870i.html";
license = licenses.unfree;
platforms = platforms.linux;
};
}
The preparation script (pstoufr2cpca):
#!/bin/sh
# Set the library path to include the directory where the Canon libraries are installed
export LD_LIBRARY_PATH="/nix/store/path-to-canon-libs:$LD_LIBRARY_PATH"
# Execute the original pstoufr2cpca binary
exec /nix/store/path-to-original-pstoufr2cpca "$@"
Note: In the preparation script, /nix/store/path-to-canon-libs and /nix/store/path-to-original-pstoufr2cpca should be replaced with the actual paths in your Nix store. These paths are typically determined at build time.
The error occurs when trying to build this package. Let me know if you need any additional information or clarification about this derivation or the preparation script.
Your pstoufr2cpca
script does something weird and package does not build as is, because this:
cp ${./pstoufr2cpca} $out/lib/cups/filter/
chmod +x $out/lib/cups/filter/pstoufr2cpca
needs to be:
cp ${./pstoufr2cpca} $out/lib/cups/filter/pstoufr2cpca
chmod +x $out/lib/cups/filter/pstoufr2cpca
${./pstoufr2cpca}
would interpolate to store path, so if you cp
as you do it would become something like 0nvb5i5baka2hjba4nd0v43dm932mwck-pstoufr2cpca
and next line with chmod
would fail.
About your error thought, I think something has windows newlines which nix can't handle.
Considering it builds fine for me by copy-pasting your code (and fixing problem above), I assume it's in .nix
file for that package you wrote.
The only refs I could find: https://stackoverflow.com/questions/78183326/how-to-fix-nix-build-failure-due-to-a-file-using-the-windows-way-to-break-line https://discourse.nixos.org/t/what-could-cause-this-flake-to-fail-on-my-computer-and-succeed-on-another/41868/2
The error occurs specifically on line 1579, which is: eval "${!curPhase:-$curPhase}"
This indicates there's a problem in your phases. Closing this but you can get support in other channels.
I'm encountering a persistent error when trying to build packages on NixOS. The error occurs in the Nix setup script, specifically on line 1579: /nix/store/bc0as359y5y067dfp7afrq1f011m9ny3-stdenv-linux/setup: line 1579: $'\r': command not found This error is preventing me from building packages, including a custom Canon printer driver package.
System Information:
Steps to Reproduce:
nixos-rebuild switch
Full Error Output:
building '/nix/store/q0qfr9f72n8gf26wcnd87wq5i2kn502c-canon-cups-ufr2-custom-5.70.drv'... Running phase: unpackPhase /nix/store/bc0as359y5y067dfp7afrq1f011m9ny3-stdenv-linux/setup: line 1579: $'\r': command not found error: builder for '/nix/store/q0qfr9f72n8gf26wcnd87wq5i2kn502c-canon-cups-ufr2-custom-5.70.drv' failed with exit code 127 error: 1 dependencies of derivation '/nix/store/j95fimzqbq8qja80h6fn2vlmg6979807-X-Restart-Triggers-systemd-udevd.drv' failed to build error: 1 dependencies of derivation '/nix/store/8la17r5zbv3q4w09plqswh8x7ynqdl8v-cups-progs.drv' failed to build error: 1 dependencies of derivation '/nix/store/jjwj0b0k1i2d22lr28lr3hbj8l36y3r2-hwdb.bin.drv' failed to build error: 1 dependencies of derivation '/nix/store/fwrn6w0915rhm6jwg6lqqih7fd7223ca-unit-script-add-canon-printer-start.drv' failed to build error: 1 dependencies of derivation '/nix/store/f5ria032hpr3h40mmlxk0xv20krzrv0i-etc.drv' failed to build error: 1 dependencies of derivation '/nix/store/lml2y7gpy1qdw9klcryyylig4xxxam75-nixos-system-nixos-24.05.4169.797f7dc49e0b.drv' failed to build
Things I've Tried:
dos2unix
on all filesgnutar
instead of the defaulttar
for extractionnix-store --verify --check-contents
andnix-store --repair
find
,xargs
, anddos2unix
in the derivationNone of these attempts have resolved the issue. The error persists in the Nix setup script itself, suggesting it might be a core Nix issue rather than a problem with my specific derivation.
Additional Information:
Questions:
Any assistance or insight into this issue would be greatly appreciated. Thank you for your time and effort in addressing this problem.
Additional Information:
The content of lines 1574-1584 in the setup script (/nix/store/bc0as359y5y067dfp7afrq1f011m9ny3-stdenv-linux/setup) is:
The error occurs specifically on line 1579, which is: eval "${!curPhase:-$curPhase}"