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