[root@elsinor:~]# nixos-rebuild switch
building Nix...
building the system configuration...
these 2 derivations will be built:
/nix/store/rvw6vbss3hkf70x65jlcnaliadwqsdrl-etc.drv
/nix/store/zn34r0v9glvwnrnbihsf46m5aa52zffj-nixos-system-elsinor-24.05.6206.d063c1dd113c.drv
building '/nix/store/rvw6vbss3hkf70x65jlcnaliadwqsdrl-etc.drv'...
ln: failed to create symbolic link '/nix/store/q1qs6zdkdzbbg4n96iljr75ibdyqngmj-etc/etc/sane-config/samsung.conf': Permission denied
error: builder for '/nix/store/rvw6vbss3hkf70x65jlcnaliadwqsdrl-etc.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/zn34r0v9glvwnrnbihsf46m5aa52zffj-nixos-system-elsinor-24.05.6206.d063c1dd113c.drv' failed to build
the error is because your file conflicts with the fact that the SANE nixos module manages the full /etc/sane.d folder. You have to go through the interface of the module to inject your configuration file. A variation of this should work:
Also you changed destination = "/etc/sane.d/samsung.conf"; to destination = "/etc/sane-config/samsung.conf"; but this is not correct. Have a look at the layout of the sane package:
The nixos module collects the contents of all the sane backends’ etc/sane.d/ directories and make a symlink to the result at /etc/sane-config. As you are providing a backend, the file must be at /nix/store/whatever/etc/sane.d
lists several files (since I ran nixos-rebuild many times) but nothing under /etc so the problem is how to get nixos-rebuild to symlink to the file it has created under /nix/store.
I don’t know what I was doing wrong before but I took care to copy the hardware.sane.extraBackends extract verbatim and now it works.
The problem now is that the scanner was turned off when the PC was booted and I can’t see how to make SANE realise that the scanner is now on. sane-find-scanner doesn’t do it and nor does scanimage -L.
Yes you need to keep the filename mentioned in man sane-xerox_mfp.
I don’t think you can append to it, but replacing the file should be doable by replacing samsung.conf by xerox_mfp.conf in the code snippet. If it complains about collision you can use lib.hiPrio to make your version of the file win over the default one.