[Nix-dev] Error: invalid printer model name

2017-06-26 Thread Nawal Husnoo
Thanks for your help, I don't really know why I keep missing the obvious :P

I've now compiled the pstocanonij you suggested, but unfortunately:

Jun 20 21:23:51 heisenbug cupsd[21991]: pstocanonij:
/home/nawal/.nix-profile/bin//gs -sstdout=%stderr -r600 -g4958x7016 -q
-dNOPROMPT -dSAFER -sDEVICE=ppmraw -sOutputFile=%stdout -|
/home/nawal/.nix-profile/bin//cifmp250 --imageres 600 --papersize a4
--media plain --paperload  asf --bbox 9,14,586,834 --fit  --copies 1
Jun 20 21:23:51 heisenbug cupsd[21991]: Error: invalid printer model name
Jun 20 21:23:51 heisenbug cupsd[21991]: Read 324 bytes of back-channel
data...
Jun 20 21:23:52 heisenbug cupsd[21991]: Wrote 1 pages...
Jun 20 21:23:52 heisenbug cupsd[21991]: PID 30211 (pstops) exited with no
errors.


[nawal@heisenbug:~/data/nixos/user/pkgs/canon]$ grep "invalid printer model
name" -R ./cnijfilter-common/cnijfilter-3.40/src/bjfoption.c
fprintf(stderr, "Error: invalid printer model name\n");

A bit of googling suggests the "model name" isn't quite what's in the ppd
file...

[nawal@heisenbug:~/data/nixos/user/pkgs/canon]$ grep Name -R ./usr/| grep
ppd | grep Model
./usr/share/ppd/canonmp250.ppd:*ModelName: "Canon MP250 series"

I think this might be where I leave the rabbit hole...



On 20 June 2017 at 20:57, Kirill Elagin <kirela...@gmail.com> wrote:

> Well, the log you posted is pretty clear on that: `pstocanonij` is calling
> it. Googling `pstocanonij` gives me this:
>
> https://github.com/endlessm/cnijfilter-common/blob/master/
> pstocanonij/filter/pstocanonij.c#L45-L52
>
> and sure enough
>
> https://github.com/endlessm/cnijfilter-common/blob/master/
> pstocanonij/filter/pstocanonij.c#L687-L695
>
> Now, the question is what to do. It looks like the source of `pstocanonij`
> is public (but you‘ll have to check what is this github repository, and
> where does the code come from, to be on the safe side with the licence,
> especially if you want to submit this expression to nixpkgs later). If this
> part of the driver is really opensource, than the answer is obvious, you
> just go there and fix the paths ;).
>
> On Tue, Jun 20, 2017 at 10:33 PM Nawal Husnoo <na...@husnoo.com> wrote:
>
>> Ah the lesson is I need to wake up fully before coding! Thank you!
>>
>> Still stuck - so close and yet so far!
>>
>> Error:
>> ==
>>
>> Jun 20 20:17:17 heisenbug cupsd[21991]: pstocanonij: /usr/bin/gs -r600
>> -g4958x7016 -q -dNOPROMPT -dSAFER -sDEVICE=ppmraw -sOutputFile=- -|
>> /usr/bin/cifmp250 --imageres 600 --papersize a4 --media plain --paperload
>> asf --bbox 9,14,586,834 --fit
>> Jun 20 20:17:17 heisenbug cupsd[21991]: /bin/sh: /usr/bin/gs: No such
>> file or directory
>> Jun 20 20:17:17 heisenbug cupsd[21991]: /bin/sh: /usr/bin/cifmp250: No
>> such file or directory
>> Jun 20 20:17:17 heisenbug cupsd[21991]: Sent 0 bytes...
>>
>> Of course, the files /usr/bin/gs and /usr/bin/cifmp250 don't exist, this
>> being nix and all...
>>
>>
>> [nawal@heisenbug:~/data/nixos/user/pkgs/canon]$ which gs
>> /home/nawal/.nix-profile/bin/gs
>>
>> [nawal@heisenbug:~/data/nixos/user/pkgs/canon]$ which cifmp250
>> /home/nawal/.nix-profile/bin/cifmp250
>>
>> Closest thing I found was:
>> https://github.com/NixOS/nixpkgs/blob/master/pkgs/misc/
>> cups/drivers/canon/default.nix
>> https://github.com/NixOS/nixpkgs/blob/master/pkgs/misc/
>> cups/drivers/canon/preload.c
>>
>> but it's not clear to me how to port that to my problem... It's not even
>> clear to me who's calling these two binaries, as grepping the deb file
>> contents isn't turning up anything...
>>
>> thanks for any ideas!
>>
>> Nawal
>>
>>
>>
>>
>> default.nix
>> ==
>> { stdenv
>> , pkgs
>> , udev
>> , alsaLib
>> , gtk2-x11
>> , patchelf
>> , binutils
>> , popt
>> , cups
>> , cairo
>> , pango
>> , fontconfig
>> , glib
>> , dpkg
>> , atk
>> , procps
>> , gdk_pixbuf
>> , zlib
>> , libxml2
>> , perl
>> , libtiff
>> , firefox
>> , libX11
>> , libXcursor
>> , libXrandr
>> , libXext
>> , libXinerama
>> , libXrender
>> , libXi
>> , libXfixes
>> , libpng12
>> , pkgconfig
>> }:
>>
>> stdenv.mkDerivation {
>> name = "canon-mp250";
>> src = ./usr;
>> builder = ./builder.sh;
>> buildInputs = [libtiff perl pkgconfig];
>>
>> configurePhase = ''
>> echo "CONFIGURE TIFF ${libtiff.out}/lib/lib

Re: [Nix-dev] canon printer drivers (cnijfilter)

2017-06-22 Thread Nawal Husnoo
pe font data
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib/cnbpname328.tbl:
> TrueType font data
>
> that's what my https://github.com/jerith666/
> <https://github.com/jerith666/nixpkgs/commit/446b9230fbde3c71e8a285180614c32cdb2cf051>
> nixpkgs/commit/
> <https://github.com/jerith666/nixpkgs/commit/446b9230fbde3c71e8a285180614c32cdb2cf051>
> 446b9230fbde3c71e8a285180614c32cdb2cf051
> <https://github.com/jerith666/nixpkgs/commit/446b9230fbde3c71e8a285180614c32cdb2cf051>
> "try using shorter libpath via /var/lib/cups" was trying to remedy, to let
> these libs be found via:
>
> $ ls -l /var/lib/cups/path/lib/bjlib
> lrwxrwxrwx 1 root root 69 Dec 31  1969 /var/lib/cups/path/lib/bjlib ->
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib
>
> But, that doesn't seem to have worked ... or, I'm still barking up the
> wrong tree.
>
> Anyway, that's what I've got for tonight ... maybe more tomorrow ... I
> think the next step is to try to fire up gdb again and see *what* file it's
> trying to open down inside that call to CNCL_SetParam().
>
>
> On Wed, Jun 21, 2017 at 7:47 AM, Matt McHenry <m...@mchenryfamily.org>
> wrote:
>
>> The error doesn't show up in the cups log -- the only thing it says is
>> "Error: CNCL_SetParam" -- but to cups, the process it spawned seems to have
>> succeeded.  See attached log.
>>
>> As I recall, the problem is that one of the executables that gets built
>> then tries to load one of binary libraries included in the tarball from
>> canon, and can't find it.  I'll have to go refresh my memory some more, but
>> won't have time until this evening.
>>
>> I have not tried patchelf -- that may be a good lead.
>>
>> I don't think a FHS env will work, because as you say, the cups service
>> can't be run in there.
>>
>> On Wed, Jun 21, 2017 at 2:36 AM, Nawal Husnoo <na...@husnoo.com> wrote:
>>
>>> Thanks for that Matt!
>>>
>>> I wonder if the versioning thing is a windows-related behaviour.
>>>
>>> Could you say a few words about the link errors you had? Have you used
>>> patchelf?
>>>
>>> >* patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
>>> *>* --set-rpath $libPath:$out/lib \
>>> *>* $out/bin/cngpijmonmp250*
>>>
>>> Another option I could live with is if we could create a buildFHSUserEnv
>>> - I tried it with the binary canon drivers, but it turned out it's cups
>>> that needs to be inside for the pesky things to be found, but then systemd
>>> wouldn't let me restart cups.service inside a user env...
>>>
>>> Cheers,
>>>
>>> Nawal.
>>>
>>>
>>>
>>> On 21 June 2017 at 01:49, Matt McHenry <m...@mchenryfamily.org> wrote:
>>>
>>>> Hi Nawal,
>>>>
>>>> I see you've been trying to get canon's linux drivers working on nixos
>>>> [1][2][3].  I've also tried my hand at this.  I think I've made more
>>>> progress than you, but was never able to get it working, and eventually
>>>> resigned myself to just printing with the gutenprint driver.  I'd be
>>>> interested in continuing to hack at it as time permits, though.
>>>>
>>>> I got to the point of cups executing what I think is the correct chain
>>>> of filters, all built from the source that my nix expression pulls from the
>>>> Canon Japan website.  However, at least one of the filters is unable to
>>>> load at least one dynamically linked library, so it fails.  I don't know
>>>> much about shared libraries on linux in general or NixOS in particular, so
>>>> I was mostly just thrashing around a lot.
>>>>
>>>> I've pushed what I have to the cnijfilter branch in my nixpkgs clone
>>>> [4].  To try it, just add pkgs.cnijfilter to services.printing.drivers in
>>>> configuration.nix.  (I also tried adding cnijfilter to
>>>> environment.systemPackages, that didn't seem to help.)
>>>>
>>>> I've gleaned a lot from the other distros builds [5][6][7].  In
>>>> particular, the cnijfilter-common library does not follow a normal
>>>> versioning pattern -- each version supports a certain set of printers.  So
>>>> you don't want the latest, you want whatever matches up with your printer.
>>>> (My printer is an MX-700, which uses the mp520 driver.  So I've been
>>>> working on version 2.80 of cnijfilter-common.)  But my hope is that 

Re: [Nix-dev] canon printer drivers (cnijfilter)

2017-06-21 Thread Nawal Husnoo
Thanks for that Matt!

I wonder if the versioning thing is a windows-related behaviour.

Could you say a few words about the link errors you had? Have you used
patchelf?

>* patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
*>* --set-rpath $libPath:$out/lib \
*>* $out/bin/cngpijmonmp250*

Another option I could live with is if we could create a buildFHSUserEnv -
I tried it with the binary canon drivers, but it turned out it's cups that
needs to be inside for the pesky things to be found, but then systemd
wouldn't let me restart cups.service inside a user env...

Cheers,

Nawal.



On 21 June 2017 at 01:49, Matt McHenry  wrote:

> Hi Nawal,
>
> I see you've been trying to get canon's linux drivers working on nixos
> [1][2][3].  I've also tried my hand at this.  I think I've made more
> progress than you, but was never able to get it working, and eventually
> resigned myself to just printing with the gutenprint driver.  I'd be
> interested in continuing to hack at it as time permits, though.
>
> I got to the point of cups executing what I think is the correct chain of
> filters, all built from the source that my nix expression pulls from the
> Canon Japan website.  However, at least one of the filters is unable to
> load at least one dynamically linked library, so it fails.  I don't know
> much about shared libraries on linux in general or NixOS in particular, so
> I was mostly just thrashing around a lot.
>
> I've pushed what I have to the cnijfilter branch in my nixpkgs clone [4].
> To try it, just add pkgs.cnijfilter to services.printing.drivers in
> configuration.nix.  (I also tried adding cnijfilter to
> environment.systemPackages, that didn't seem to help.)
>
> I've gleaned a lot from the other distros builds [5][6][7].  In
> particular, the cnijfilter-common library does not follow a normal
> versioning pattern -- each version supports a certain set of printers.  So
> you don't want the latest, you want whatever matches up with your printer.
> (My printer is an MX-700, which uses the mp520 driver.  So I've been
> working on version 2.80 of cnijfilter-common.)  But my hope is that the
> overall structure of the build would be very portable between versions.
>
> It looks like you've worked from the debian packages -- perhaps looking in
> more detail at how they are built will give us some more clues?
>
> I'm not sure whether it makes more sense to open an issue to document this
> work, or keep discussing on the mailing list.
>
> [1] https://mailman.science.uu.nl/pipermail/nix-dev/2017-June/023942.html
> [2] https://mailman.science.uu.nl/pipermail/nix-dev/2017-June/023943.html
> [3] https://mailman.science.uu.nl/pipermail/nix-dev/2017-June/023946.html
>
> [4] https://github.com/jerith666/nixpkgs/tree/cnijfilter
>
> [5] https://bugs.gentoo.org/show_bug.cgi?id=130645
> [6] https://aur.archlinux.org/packages/cnijfilter-mp620/?comments=all
> [7] https://github.com/spremi/cnijfilter-source-3.80
>
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


[Nix-dev] /usr/bin/gs and /usr/bin/cifmp250

2017-06-20 Thread Nawal Husnoo
Ah the lesson is I need to wake up fully before coding! Thank you!

Still stuck - so close and yet so far!

Error:
==

Jun 20 20:17:17 heisenbug cupsd[21991]: pstocanonij: /usr/bin/gs -r600
-g4958x7016 -q -dNOPROMPT -dSAFER -sDEVICE=ppmraw -sOutputFile=- -|
/usr/bin/cifmp250 --imageres 600 --papersize a4 --media plain --paperload
asf --bbox 9,14,586,834 --fit
Jun 20 20:17:17 heisenbug cupsd[21991]: /bin/sh: /usr/bin/gs: No such file
or directory
Jun 20 20:17:17 heisenbug cupsd[21991]: /bin/sh: /usr/bin/cifmp250: No such
file or directory
Jun 20 20:17:17 heisenbug cupsd[21991]: Sent 0 bytes...

Of course, the files /usr/bin/gs and /usr/bin/cifmp250 don't exist, this
being nix and all...


[nawal@heisenbug:~/data/nixos/user/pkgs/canon]$ which gs
/home/nawal/.nix-profile/bin/gs

[nawal@heisenbug:~/data/nixos/user/pkgs/canon]$ which cifmp250
/home/nawal/.nix-profile/bin/cifmp250

Closest thing I found was:
https://github.com/NixOS/nixpkgs/blob/master/pkgs/misc/cups/drivers/canon/default.nix
https://github.com/NixOS/nixpkgs/blob/master/pkgs/misc/cups/drivers/canon/preload.c

but it's not clear to me how to port that to my problem... It's not even
clear to me who's calling these two binaries, as grepping the deb file
contents isn't turning up anything...

thanks for any ideas!

Nawal




default.nix
==
{ stdenv
, pkgs
, udev
, alsaLib
, gtk2-x11
, patchelf
, binutils
, popt
, cups
, cairo
, pango
, fontconfig
, glib
, dpkg
, atk
, procps
, gdk_pixbuf
, zlib
, libxml2
, perl
, libtiff
, firefox
, libX11
, libXcursor
, libXrandr
, libXext
, libXinerama
, libXrender
, libXi
, libXfixes
, libpng12
, pkgconfig
}:

stdenv.mkDerivation {
name = "canon-mp250";
src = ./usr;
builder = ./builder.sh;
buildInputs = [libtiff perl pkgconfig];

configurePhase = ''
echo "CONFIGURE TIFF ${libtiff.out}/lib/libtiff.so"
'';

libPath = stdenv.lib.makeLibraryPath [
stdenv.cc.cc
udev
alsaLib
gtk2-x11
binutils
popt
cups
cairo
pango
fontconfig
glib
dpkg
atk
procps
patchelf
gdk_pixbuf
libxml2
libtiff
libpng12
libX11
libXcursor
libXrandr
libXext
libXinerama
libXrender
libXi
libXfixes
];

}





builder.sh
==
source $stdenv/setup

mkdir -p $out/
cp -r $src/* $out/


chmod 777 -R $out/*

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cngpijmonmp250

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cngpij

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cnijnetprn

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/lgmonmp250

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cifmp250

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/printuimp250

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cnijnpr

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/lib/cups/filter/pstocanonij

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/lib/cups/backend/cnijusb

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/lib/cups/backend/cnijnet

ls -lh $out/lib/
ls -lh $out/

ln -sv $out/lib/libcnbpcmcm356.so.8.0.1 $out/lib/libcnbpcmcm356.so
ln -sv $out/lib/libcnbpcnclbjcmd356.so.3.3.0 $out/lib/libcnbpcnclbjcmd356.so
ln -sv $out/lib/libcnbpess356.so.3.3.3 $out/lib/libcnbpess356.so
ln -sv $out/lib/libcnnet.so.1.2.0 $out/lib/libcnnet.so
ln -sv $out/lib/libcnbpcnclapi356.so.3.5.0 $out/lib/libcnbpcnclapi356.so
ln -sv $out/lib/libcnbpcnclui356.so.3.6.0 $out/lib/libcnbpcnclui356.so
ln -sv $out/lib/libcnbpo356.so.1.0.2 $out/lib/libcnbpo356.so

LIBTIFF=$(pkg-config --libs-only-L libtiff-4 | sed -e
's/-L//g')/libtiff.so.5
ln -s $LIBTIFF $out/lib/libtiff.so.4






On 20 June 2017 at 10:11, Kirill Elagin <kirela...@gmail.com> wrote:

> You do `chmod 777` on a bunch of files, but not on `$out/lib`, but it’s
> the creation of a link in `$out/lib` that fails, and according to your
> output of `ls` the `lib` directory does not have the `w` permission indeed,
> which is required to create a link in it.
>
> I am not sure how this works exactly, but it seems that `cp` removes the
> `w` permission when copying, so you either have to reset this permissions
> yourself or, probably simpler, `mkdir -p "

Re: [Nix-dev] printing on nix

2017-06-20 Thread Nawal Husnoo
Thanks for the suggestion! I'm now trying to get it to build as a proper
package so that cups can access it...

On 20 June 2017 at 08:09, Kirill Elagin <kirela...@gmail.com> wrote:

> I’m not quite sure, but I always thought CUPS was searching for the filter
> in the PATH:
>
> https://github.com/NixOS/nixpkgs/blob/50fadc8b18fb3da6bda2f3710009a1
> 5f6ac45567/nixos/modules/services/printing/cupsd.nix#L79
>
> I don’t think the NixOS module has a simple way to adjust PATH, but you
> could try to put the filter into one of the mentioned directories.
>
> Another option that should definitely work is to replace the filter name
> with the absolute path in the ppd file itself.
>
> On Tue, Jun 20, 2017 at 12:55 AM Nawal Husnoo <na...@husnoo.com> wrote:
>
>> Hi,
>>
>> I've got the default.nix below, and I run it using nix-shell. I opened
>> firefox, and went to 127.0.0.1:631 and added a printer, and selected the
>> ppd file from /opt/share/ppd/canonmp250.ppd.
>>
>> Unfortunately, when I try to print a test page I get the error message:
>>
>> Idle - "File "/nix/store/wy6c4mlp6zhjj4j3cjwrhwfi4ba9bx
>> ab-cups-progs/lib/cups/filter/pstocanonij" not available: No such file
>> or directory"
>>
>> The file lives at /opt/lib/cups/filter/pstocanonij.
>>
>> How do I override cups path in nix?
>>
>> thanks,
>>
>> Nawal.
>>
>>
>> { pkgs ? import  {}}:
>>
>> (pkgs.buildFHSUserEnv {
>> name = "simple-x11-env";
>> targetPkgs = pkgs: (with pkgs; [
>> udev
>> alsaLib
>> gtk2-x11
>> patchelf
>> binutils
>> popt
>> cups
>> dpkg
>> cairo
>> pango
>> fontconfig
>> glib
>> dpkg
>> atk
>> gdk_pixbuf
>> libxml2
>> libtiff
>> firefox
>> ]) ++ (with pkgs.xorg; [
>> libX11
>> libXcursor
>> libXrandr
>> libXext
>> libXinerama
>> libXrender
>> libXi
>> libXfixes
>> ]);
>> multiPkgs = pkgs: (with pkgs; [
>> ]);
>>
>> extraBuildCommands = ''
>> echo "instaling environment for cups printing with canon mp
>> 250..."
>>
>> ls -lh $out/
>> mkdir -p $out/opt/bin/
>> mkdir -p $out/opt/lib/
>> cp -r /home/nawal/data/nixos/user/pkgs/canon/tmp/cnijfilter-common/usr/bin/*
>> $out/opt/bin/
>> cp -r 
>> /home/nawal/data/nixos/user/pkgs/canon/tmp/cnijfilter-common/usr/share/*
>> $out/opt/share/
>> cp -r /home/nawal/data/nixos/user/pkgs/canon/tmp/cnijfilter-common/usr/lib/*
>> $out/opt/lib/
>>
>> cp -r 
>> /home/nawal/data/nixos/user/pkgs/canon/tmp/cnijfilter-mp250series/usr/bin/*
>> $out/opt/bin/
>> cp -r 
>> /home/nawal/data/nixos/user/pkgs/canon/tmp/cnijfilter-mp250series/usr/share/*
>> $out/opt/share/
>> cp -r 
>> /home/nawal/data/nixos/user/pkgs/canon/tmp/cnijfilter-mp250series/usr/lib/*
>> $out/opt/lib/
>>
>> ln -s $out/opt/lib/libcnbpcmcm356.so.8.0.1 $out/opt/lib/libcnbpcmcm356.so
>> ln -s $out/opt/lib/libcnbpcnclbjcmd356.so.3.3.0 $out/opt/lib/
>> libcnbpcnclbjcmd356.so
>> ln -s $out/opt/lib/libcnbpess356.so.3.3.3 $out/opt/lib/libcnbpess356.so
>> ln -s $out/opt/lib/libcnnet.so.1.2.0 $out/opt/lib/libcnnet.so
>> ln -s $out/opt/lib/libcnbpcnclapi356.so.3.5.0 $out/opt/lib/
>> libcnbpcnclapi356.so
>> ln -s $out/opt/lib/libcnbpcnclui356.so.3.6.0
>> $out/opt/lib/libcnbpcnclui356.so
>> ln -s $out/opt/lib/libcnbpo356.so.1.0.2 $out/opt/lib/libcnbpo356.so
>>
>>
>> echo "OUT=$out"
>> '';
>>
>> profile = ''
>> export LD_LIBRARY_PATH=$out/opt/lib:$LD_LIBRARY_PATH
>> export PATH=$out/opt/bin:$PATH
>> export TZDIR=/etc/zoneinfo
>> '';
>>
>> runScript = ''
>> bash
>> '';
>> }).env
>>
>>
>> #${dpkg}/bin/dpkg -x ./debs/cnijfilter-common_3.40-1_amd64.deb
>> tmp/cnijfilter-common
>> #${dpkg}/bin/dpkg -x ./debs/cnijfilter-mp250series_3.40-1_amd64.deb
>> tmp/cnijfilter-mp250series
>>
>> ___
>> nix-dev mailing list
>> nix-dev@lists.science.uu.nl
>> https://mailman.science.uu.nl/mailman/listinfo/nix-dev
>>
>
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


[Nix-dev] symlink permission denied in builder.sh

2017-06-20 Thread Nawal Husnoo
Hi

I have the following default.nix and builder.sh, copied from the acroread
example and adapted. They are called from config.nix. I'm getting
permission denied when I try to create a symbolic link. Any ideas?

thanks

Nawal


Error:

[nawal@heisenbug:~/data/nixos/user/pkgs/canon]$  nix-env -i all
warning: there are multiple derivations named ‘all’; using the first one
replacing old ‘all’
installing ‘all’
these derivations will be built:
  /nix/store/w1w639kybx0lgvdmnb9ipg0j1xvb9wlq-canon-mp250.drv
  /nix/store/bmp2ibgc82rmx14bgavd3pknwxwdp4ld-all.drv
building path(s) ‘/nix/store/q5qyxyqrfscdv7yj6aywx9v518215wdr-canon-mp250’
total 764K
dr-xr-xr-x 2 nixbld1 nixbld 4.0K Jun 20 08:23 bjlib
dr-xr-xr-x 4 nixbld1 nixbld 4.0K Jun 20 08:23 cups
-r-xr-xr-x 1 nixbld1 nixbld  47K Jun 20 08:23 libcnbpcmcm356.so.8.0.1
-r-xr-xr-x 1 nixbld1 nixbld  41K Jun 20 08:23 libcnbpcnclapi356.so.3.5.0
-r-xr-xr-x 1 nixbld1 nixbld  21K Jun 20 08:23 libcnbpcnclbjcmd356.so.3.3.0
-r-xr-xr-x 1 nixbld1 nixbld  29K Jun 20 08:23 libcnbpcnclui356.so.3.6.0
-r-xr-xr-x 1 nixbld1 nixbld 522K Jun 20 08:23 libcnbpess356.so.3.3.3
-r-xr-xr-x 1 nixbld1 nixbld  42K Jun 20 08:23 libcnbpo356.so.1.0.2
-r-xr-xr-x 1 nixbld1 nixbld  38K Jun 20 08:23 libcnnet.so.1.2.0
total 12K
dr-xr-xr-x 2 nixbld1 nixbld 4.0K Jun 20 08:23 bin
dr-xr-xr-x 4 nixbld1 nixbld 4.0K Jun 20 08:23 lib
dr-xr-xr-x 7 nixbld1 nixbld 4.0K Jun 20 08:23 share
ln: failed to create symbolic link
'/nix/store/q5qyxyqrfscdv7yj6aywx9v518215wdr-canon-mp250/lib/libcnbpcmcm356.so':
Permission denied
builder for ‘/nix/store/w1w639kybx0lgvdmnb9ipg0j1xvb9wlq-canon-mp250.drv’
failed with exit code 1
cannot build derivation
‘/nix/store/bmp2ibgc82rmx14bgavd3pknwxwdp4ld-all.drv’: 1 dependencies
couldn't be built
error: build of ‘/nix/store/bmp2ibgc82rmx14bgavd3pknwxwdp4ld-all.drv’ failed



config.nix
with import  {};

{
allowUnfree = true;

packageOverrides = pkgs_: with pkgs_; {
canon = callPackage ./pkgs/canon {
inherit (pkgs) pkgs;
};


all = with pkgs; buildEnv {
name = "all";
paths = [
canon
];
};
};
}


default.nix:
{ stdenv
, pkgs
, udev
, alsaLib
, gtk2-x11
, patchelf
, binutils
, popt
, cups
, cairo
, pango
, fontconfig
, glib
, dpkg
, atk
, procps
, gdk_pixbuf
, zlib
, libxml2
, libtiff
, firefox
, libX11
, libXcursor
, libXrandr
, libXext
, libXinerama
, libXrender
, libXi
, libXfixes
}:

stdenv.mkDerivation {
name = "canon-mp250";
src = ./usr;
builder = ./builder.sh;
libPath = stdenv.lib.makeLibraryPath [
stdenv.cc.cc
udev
alsaLib
gtk2-x11
binutils
popt
cups
cairo
pango
fontconfig
glib
dpkg
atk
procps
patchelf
gdk_pixbuf
libxml2
libtiff
libX11
libXcursor
libXrandr
libXext
libXinerama
libXrender
libXi
libXfixes
];

}


builder.sh:
source $stdenv/setup

mkdir -p $out/
cp -r $src/* $out/


chmod 777 -R $out/bin/*
chmod 777 -R $out/lib/cups/filter/*
chmod 777 -R $out/lib/cups/backend/*

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cngpijmonmp250

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cngpij

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cnijnetprn

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/lgmonmp250

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cifmp250

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/printuimp250

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cnijnpr

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/lib/cups/filter/pstocanonij

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/lib/cups/backend/cnijusb

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/lib/cups/backend/cnijnet

ls -lh $out/lib/
ls -lh $out/

ln -sv $out/lib/libcnbpcmcm356.so.8.0.1 $out/lib/libcnbpcmcm356.so
ln -sv $out/lib/libcnbpcnclbjcmd356.so.3.3.0 $out/lib/libcnbpcnclbjcmd356.so
ln -sv $out/lib/libcnbpess356.so.3.3.3 $out/lib/libcnbpess356.so
ln -sv $out/lib/libcnnet.so.1.2.0 $out/lib/libcnnet.so
ln -sv $out/lib/libcnbpcnclapi356.so.3.5.0 $out/lib/libcnbpcnclapi356.so
ln -sv $out/lib/libcnbpcnclui356.so.3.6.0 $out/lib/libcnbpcnclui356.so
ln -sv $out/lib/libcnbpo356.so.1.0.2 $out/lib/libcnbpo356.so
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


[Nix-dev] printing on nix

2017-06-19 Thread Nawal Husnoo
Hi,

I've got the default.nix below, and I run it using nix-shell. I opened
firefox, and went to 127.0.0.1:631 and added a printer, and selected the
ppd file from /opt/share/ppd/canonmp250.ppd.

Unfortunately, when I try to print a test page I get the error message:

Idle - "File
"/nix/store/wy6c4mlp6zhjj4j3cjwrhwfi4ba9bxab-cups-progs/lib/cups/filter/pstocanonij"
not available: No such file or directory"

The file lives at /opt/lib/cups/filter/pstocanonij.

How do I override cups path in nix?

thanks,

Nawal.


{ pkgs ? import  {}}:

(pkgs.buildFHSUserEnv {
name = "simple-x11-env";
targetPkgs = pkgs: (with pkgs; [
udev
alsaLib
gtk2-x11
patchelf
binutils
popt
cups
dpkg
cairo
pango
fontconfig
glib
dpkg
atk
gdk_pixbuf
libxml2
libtiff
firefox
]) ++ (with pkgs.xorg; [
libX11
libXcursor
libXrandr
libXext
libXinerama
libXrender
libXi
libXfixes
]);
multiPkgs = pkgs: (with pkgs; [
]);

extraBuildCommands = ''
echo "instaling environment for cups printing with canon mp 250..."

ls -lh $out/
mkdir -p $out/opt/bin/
mkdir -p $out/opt/lib/
cp -r
/home/nawal/data/nixos/user/pkgs/canon/tmp/cnijfilter-common/usr/bin/*
$out/opt/bin/
cp -r
/home/nawal/data/nixos/user/pkgs/canon/tmp/cnijfilter-common/usr/share/*
$out/opt/share/
cp -r
/home/nawal/data/nixos/user/pkgs/canon/tmp/cnijfilter-common/usr/lib/*
$out/opt/lib/

cp -r
/home/nawal/data/nixos/user/pkgs/canon/tmp/cnijfilter-mp250series/usr/bin/*
$out/opt/bin/
cp -r
/home/nawal/data/nixos/user/pkgs/canon/tmp/cnijfilter-mp250series/usr/share/*
$out/opt/share/
cp -r
/home/nawal/data/nixos/user/pkgs/canon/tmp/cnijfilter-mp250series/usr/lib/*
$out/opt/lib/

ln -s $out/opt/lib/libcnbpcmcm356.so.8.0.1 $out/opt/lib/libcnbpcmcm356.so
ln -s $out/opt/lib/libcnbpcnclbjcmd356.so.3.3.0
$out/opt/lib/libcnbpcnclbjcmd356.so
ln -s $out/opt/lib/libcnbpess356.so.3.3.3 $out/opt/lib/libcnbpess356.so
ln -s $out/opt/lib/libcnnet.so.1.2.0 $out/opt/lib/libcnnet.so
ln -s $out/opt/lib/libcnbpcnclapi356.so.3.5.0
$out/opt/lib/libcnbpcnclapi356.so
ln -s $out/opt/lib/libcnbpcnclui356.so.3.6.0
$out/opt/lib/libcnbpcnclui356.so
ln -s $out/opt/lib/libcnbpo356.so.1.0.2 $out/opt/lib/libcnbpo356.so


echo "OUT=$out"
'';

profile = ''
export LD_LIBRARY_PATH=$out/opt/lib:$LD_LIBRARY_PATH
export PATH=$out/opt/bin:$PATH
export TZDIR=/etc/zoneinfo
'';

runScript = ''
bash
'';
}).env


#${dpkg}/bin/dpkg -x ./debs/cnijfilter-common_3.40-1_amd64.deb
tmp/cnijfilter-common
#${dpkg}/bin/dpkg -x ./debs/cnijfilter-mp250series_3.40-1_amd64.deb
tmp/cnijfilter-mp250series
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


[Nix-dev] Python: Provide your own buildPhase and installPhase.

2017-05-26 Thread Nawal Husnoo
Hi,

Could anyone point me to an example where I can see this in action please?

https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/interpreters/python/build-python-package.nix
# "other" : Provide your own buildPhase and installPhase.

Say I copy the build-python-package-flit.nix file as
build-python-package-panda3d.nix - how do I get my default.nix to use this?

My current attempt:

with import  {};

# nix-shell

# python2.7 makepanda/makepanda.py --everything --wheel --no-egl --no-gles
--no-gles2 --no-opencv  --use-x11 --use-python --use-gl --use-fftw
--use-gtk2 --python-incdir
/nix/store/3n3r10921c0mzfrq64hc4m2jzjk13qpr-python-2.7.13/include
--python-libdir
/nix/store/3n3r10921c0mzfrq64hc4m2jzjk13qpr-python-2.7.13/lib
# pip install --prefix /home/nawal/usr
panda3d-1.10.0-cp27-cp27mu-linux_x86_64.whl
# export PYTHONPATH=/home/nawal/usr/lib/python2.7/site-packages/:$PYTHONPATH

(let

panda3d = pkgs.pythonPackages.buildPythonPackage rec{
name = "panda3d-${version}";
version = "";
src = ./panda3d;


propagatedBuildInputs =  [
xorg.libX11
xorg.xproto
pkgconfig
python
ffmpeg-full
assimp
freetype
harfbuzz
glfw
ode
openal
libtiff
openexr
vrpn
bullet
libvorbis
libjpeg
openjpeg
libpng
openssl
zlib
gtk2-x11
opusTools
x11
xorg.libX11
xorg.xproto
pythonPackages.pip
];
};

in python.buildEnv.override {
extraLibs = [
panda3d
pkgs.pythonPackages.gnureadline
];
ignoreCollisions = true;
}).env
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] The .nixpkgs/config.nix file and user configuration

2017-05-04 Thread Nawal Husnoo
Using that repo, I have been able to reach what I was looking for: my
system config uses configuration.nix, just for the system, and internet
facing stuff, where I really want to follow the release channel to make
sure I use the latest.

For my user stuff, I now have a config.nix:

$ cat ~/.config/nixpkgs/config.nix
# nix-env -i all
# https://github.com/kamilchm/.nixpkgs/blob/master/config.nix

with import  {};

{
allowUnfree = true;

packageOverrides = pkgs_: with pkgs_; {
eterm = import ./eterm {
inherit (pkgs) stdenv fetchurl pkgconfig imlib2 libast;
libX11 = xorg.libX11;
libXext = xorg.libXext;
libXaw = xorg.libXaw;
};



all = with pkgs; buildEnv {
name = "all";
paths = [
eterm
vlc
];
};
};
}

where the vlc is being pulled from the system channel, but the Eterm is
being built with my modified version of the original, to include the
unicode bits:

$ cat ~/data/nixos/user/eterm/default.nix
{ stdenv, fetchurl
, libX11, libXext, libXaw
, pkgconfig, imlib2, libast }:

stdenv.mkDerivation rec {
name = "eterm-${version}";
version = "0.9.6";
srcName = "Eterm-${version}";

src = fetchurl {
url = "http://www.eterm.org/download/${srcName}.tar.gz;;
sha256 = "0g71szjklkiczxwzbjjfm59y6v9w4hp8mg7cy99z1g7qcjm0gfbj";
};

configureFlags = "--enable-multi-charset=utf-8";

buildInputs = [ libX11 libXext libXaw pkgconfig imlib2 ];
propagatedBuildInputs = [ libast ];

meta = with stdenv.lib; {
description = "Terminal emulator";
homepage = "http://www.eterm.org;;
license = licenses.bsd2;
maintainers = [ maintainers.AndersonTorres ];
platforms = platforms.linux;
};
}

I install all of the above with nix-env -i all, as a user - so this is, if
I understand correcly, per-user as you are seeking too. Does that make
sense?
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] The .nixpkgs/config.nix file and user configuration

2017-05-03 Thread Nawal Husnoo
$ cat ~/.config/nixpkgs/config.nix
with import  {};

{
allowUnfree = true;

graphicCollection = misc.collection {
name = "foo" ;
packages = [
   vlc
];
};
}


$ nix-env -i misc.collection.graphicCollection
error: selector ‘misc.collection.graphicCollection’ matches no
derivations


On 4 May 2017 at 06:31, Marc Weber  wrote:

>
> > I don't like the idea of using nix-env,
> Why? You can also have your own declarative set of packages "per user".
> that's also something config.nix can do:
> graphicCollection = misc.collection { name = ... ; packages = [ ... . ]}
> (from head)
>
> nix-env -i graphicCollection
>
> works well for me :)
>
> Marc Weber
> ___
> nix-dev mailing list
> nix-dev@lists.science.uu.nl
> https://mailman.science.uu.nl/mailman/listinfo/nix-dev
>
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] binutils missing libbfd

2017-03-03 Thread Nawal Husnoo
Hi, I found from my old notes that I ended up using simavr before anyway...
so I've now compiled that instead, although the examples and tests gave me
grief so I rm -r themand put a dummy Makefile in the directory. Not tested
it with my code yet.

cheers,

Nawal

On 3 March 2017 at 07:35, Bjørn Forsman <bjorn.fors...@gmail.com> wrote:

> On 3 March 2017 at 00:27, Nawal Husnoo <na...@husnoo.com> wrote:
> > Hi,
> >
> > I'm trying to build simulavr, using the script below. However, it's not
> > finding *binutils-2.27/lib/libbfd.so
> >
> >
> > bfd search-
> > /nix/store/43cpb15i8jjing1gwn8rmbg80lhl8kqv-binutils-2.27/lib/libbfd.la
> in
> > "include" and ""... no
> > configure: error:
> > Could not locate libbfd.so/libbfd.a and/or bfd.h.
> >
> >
> > But it's possible to have it installed:
> >
> > $ ls /nix/store/*binutils*/lib/libbfd*
> > /nix/store/2mvblw8kq86ncaidjrp3x4rssy1lhlhi-binutils-2.27/lib/libbfd-2.
> 27.so
> > /nix/store/2mvblw8kq86ncaidjrp3x4rssy1lhlhi-binutils-2.27/lib/libbfd.la
> > /nix/store/2mvblw8kq86ncaidjrp3x4rssy1lhlhi-binutils-2.27/lib/libbfd.so
> > /nix/store/b7sf8p9fgjlrwr1ndwvwdy71lfnn02pv-binutils-2.27-lib/lib/libbf
> d-2.27.so
> > /nix/store/b7sf8p9fgjlrwr1ndwvwdy71lfnn02pv-binutils-2.27-lib/lib/libbf
> d.la
> > /nix/store/b7sf8p9fgjlrwr1ndwvwdy71lfnn02pv-binutils-2.27-lib/lib/
> libbfd.so
> > /nix/store/cwxfpjwr4fp6mhyfc46pj0apy4w4dwyr-binutils-2.27-lib/lib/libbf
> d-2.27.so
> > /nix/store/cwxfpjwr4fp6mhyfc46pj0apy4w4dwyr-binutils-2.27-lib/lib/libbf
> d.la
> > /nix/store/cwxfpjwr4fp6mhyfc46pj0apy4w4dwyr-binutils-2.27-lib/lib/
> libbfd.so
> > /nix/store/j1myzr7f9139kckijcy6yqv4l62vml8j-binutils-2.27-lib/lib/libbf
> d-2.27.so
> > /nix/store/j1myzr7f9139kckijcy6yqv4l62vml8j-binutils-2.27-lib/lib/libbf
> d.la
> > /nix/store/j1myzr7f9139kckijcy6yqv4l62vml8j-binutils-2.27-lib/lib/
> libbfd.so
>
> I had the same problem in 2014[1]. Didn't solve it :-)
>
> According to "./configure --help", the binutils package needs to be
> the one cross-compiled for AVR.
>
> Do you know how simulavr compares to simavr? simulavr seems pretty
> dead, whereas simavr maintainer just put out a release. Or is simulavr
> simply "completed"?
>
> [1]: https://github.com/bjornfor/nixpkgs/tree/avr-stuff
>
> Best regards,
> Bjørn Forsman
>
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


[Nix-dev] binutils missing libbfd

2017-03-02 Thread Nawal Husnoo
Hi,

I'm trying to build simulavr, using the script below. However, it's not
finding *binutils-2.27/lib/libbfd.so


bfd search- /nix/store/43cpb15i8jjing1gwn8rmbg80lhl8kqv-binutils-2.27/lib/
libbfd.la in "include" and ""... no
configure: error:
Could not locate libbfd.so/libbfd.a and/or bfd.h.


But it's possible to have it installed:

$ ls /nix/store/*binutils*/lib/libbfd*
/nix/store/2mvblw8kq86ncaidjrp3x4rssy1lhlhi-binutils-2.27/lib/libbfd-2.27.so
/nix/store/2mvblw8kq86ncaidjrp3x4rssy1lhlhi-binutils-2.27/lib/libbfd.la
/nix/store/2mvblw8kq86ncaidjrp3x4rssy1lhlhi-binutils-2.27/lib/libbfd.so
/nix/store/b7sf8p9fgjlrwr1ndwvwdy71lfnn02pv-binutils-2.27-lib/lib/
libbfd-2.27.so
/nix/store/b7sf8p9fgjlrwr1ndwvwdy71lfnn02pv-binutils-2.27-lib/lib/libbfd.la
/nix/store/b7sf8p9fgjlrwr1ndwvwdy71lfnn02pv-binutils-2.27-lib/lib/libbfd.so
/nix/store/cwxfpjwr4fp6mhyfc46pj0apy4w4dwyr-binutils-2.27-lib/lib/
libbfd-2.27.so
/nix/store/cwxfpjwr4fp6mhyfc46pj0apy4w4dwyr-binutils-2.27-lib/lib/libbfd.la
/nix/store/cwxfpjwr4fp6mhyfc46pj0apy4w4dwyr-binutils-2.27-lib/lib/libbfd.so
/nix/store/j1myzr7f9139kckijcy6yqv4l62vml8j-binutils-2.27-lib/lib/
libbfd-2.27.so
/nix/store/j1myzr7f9139kckijcy6yqv4l62vml8j-binutils-2.27-lib/lib/libbfd.la
/nix/store/j1myzr7f9139kckijcy6yqv4l62vml8j-binutils-2.27-lib/lib/libbfd.so


How do I select the right binutils in the default.nix below?

Thanks,

Nawal

{ stdenv, fetchurl, python, doxygen, tcl, tk, binutils }:

stdenv.mkDerivation rec {
  name = "simulavr";

  src = fetchurl {
url = "
http://download.savannah.nongnu.org/releases/simulavr/simulavr-1.0.0.tar.gz
";
sha256 =
"39d93faa3eeae2bee15f682dd6a48fb4d4366addd12a2abebb04c99f87809be7";
  };

  configureFlags = [
"--enable-python"
"--enable-doxygen-doc"
"--enable-tcl"
"--with-bfd=${binutils}/lib/libbfd.la"
  ];

  buildInputs = [ python doxygen tcl tk binutils];

  meta = {
description = "";
homepage= http://www.nongnu.org/simulavr/;
license = stdenv.lib.licenses.gpl2;
platforms   = stdenv.lib.platforms.all;
  };
}
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev