1{
2 stdenv,
3 lib,
4 brscan4,
5 netDevices ? [ ],
6}:
7
8/*
9 Testing
10 -------
11
12 No net devices:
13
14 ~~~
15 nix-shell -E 'with import <nixpkgs> { }; brscan4-etc-files'
16 ~~~
17
18 Two net devices:
19
20 ~~~
21 nix-shell -E 'with import <nixpkgs> { }; brscan4-etc-files.override{netDevices=[{name="a"; model="MFC-7860DW"; nodename="BRW0080927AFBCE";} {name="b"; model="MFC-7860DW"; ip="192.168.1.2";}];}'
22 ~~~
23*/
24
25let
26
27 addNetDev = nd: ''
28 brsaneconfig4 -a \
29 name="${nd.name}" \
30 model="${nd.model}" \
31 ${
32 if (lib.hasAttr "nodename" nd && nd.nodename != null) then
33 ''nodename="${nd.nodename}"''
34 else
35 ''ip="${nd.ip}"''
36 }'';
37 addAllNetDev = xs: lib.concatStringsSep "\n" (map addNetDev xs);
38in
39
40stdenv.mkDerivation {
41
42 pname = "brscan4-etc-files";
43 version = "0.4.3-3";
44 src = "${brscan4}/opt/brother/scanner/brscan4";
45
46 nativeBuildInputs = [ brscan4 ];
47
48 dontConfigure = true;
49
50 buildPhase = ''
51 TARGET_DIR="$out/etc/opt/brother/scanner/brscan4"
52 mkdir -p "$TARGET_DIR"
53 cp -rp "./models4" "$TARGET_DIR"
54 cp -rp "./Brsane4.ini" "$TARGET_DIR"
55 cp -rp "./brsanenetdevice4.cfg" "$TARGET_DIR"
56
57 export BRSANENETDEVICE4_CFG_FILENAME="$TARGET_DIR/brsanenetdevice4.cfg"
58
59 printf '${addAllNetDev netDevices}\n'
60
61 ${addAllNetDev netDevices}
62 '';
63
64 dontInstall = true;
65 dontStrip = true;
66 dontPatchELF = true;
67
68 meta = with lib; {
69 description = "Brother brscan4 sane backend driver etc files";
70 homepage = "http://www.brother.com";
71 platforms = platforms.linux;
72 license = licenses.unfree;
73 maintainers = with maintainers; [ jraygauthier ];
74 };
75}