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
22with lib;
23
24let
25
26 addNetDev = nd: ''
27 brsaneconfig4 -a \
28 name="${nd.name}" \
29 model="${nd.model}" \
30 ${if (hasAttr "nodename" nd && nd.nodename != null) then
31 ''nodename="${nd.nodename}"'' else
32 ''ip="${nd.ip}"''}'';
33 addAllNetDev = xs: concatStringsSep "\n" (map addNetDev xs);
34in
35
36stdenv.mkDerivation rec {
37
38 name = "brscan4-etc-files-0.4.3-3";
39 src = "${brscan4}/opt/brother/scanner/brscan4";
40
41 nativeBuildInputs = [ brscan4 ];
42
43 configurePhase = ":";
44
45 buildPhase = ''
46 TARGET_DIR="$out/etc/opt/brother/scanner/brscan4"
47 mkdir -p "$TARGET_DIR"
48 cp -rp "./models4" "$TARGET_DIR"
49 cp -rp "./Brsane4.ini" "$TARGET_DIR"
50 cp -rp "./brsanenetdevice4.cfg" "$TARGET_DIR"
51
52 export BRSANENETDEVICE4_CFG_FILENAME="$TARGET_DIR/brsanenetdevice4.cfg"
53
54 printf '${addAllNetDev netDevices}\n'
55
56 ${addAllNetDev netDevices}
57 '';
58
59 installPhase = ":";
60
61 dontStrip = true;
62 dontPatchELF = true;
63
64 meta = {
65 description = "Brother brscan4 sane backend driver etc files";
66 homepage = http://www.brother.com;
67 platforms = stdenv.lib.platforms.linux;
68 license = stdenv.lib.licenses.unfree;
69 maintainers = with stdenv.lib.maintainers; [ jraygauthier ];
70 };
71}