summary refs log tree commit diff
path: root/pkgs/applications/graphics/sane/backends/brscan4/udev_rules_type1.nix
blob: da136a7f9e1e6fb9166e2f4f3fc748e03d3ce5ab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ stdenv, fetchurl, libsaneUDevRuleNumber ? "49"}:

stdenv.mkDerivation rec {
  name = "brother-udev-rule-type1-1.0.0-1";

  src = fetchurl {
    url = "http://download.brother.com/welcome/dlf006654/${name}.all.deb";
    sha256 = "0i0x5jw135pli4jl9mgnr5n2rrdvml57nw84yq2999r4frza53xi";
  };

  dontBuild = true;

  unpackPhase = ''
    ar x $src
    tar xfvz data.tar.gz
  '';

  /*
    Fix the following error:

    ~~~
    invalid rule 49-brother-libsane-type1.rules
    unknown key 'SYSFS{idVendor}'
    ~~~

    Apparently the udev rules syntax has change and the SYSFS key has to
    be changed to ATTR.

    See:

     -  <http://ubuntuforums.org/showthread.php?t=1496878>
     -  <http://www.planet-libre.org/index.php?post_id=10937>
  */
  patchPhase = ''
    sed -i -e s/SYSFS/ATTR/g opt/brother/scanner/udev-rules/type1/*.rules
  '';

  installPhase = ''
    mkdir -p $out/etc/udev/rules.d
    cp opt/brother/scanner/udev-rules/type1/NN-brother-mfp-type1.rules \
      $out/etc/udev/rules.d/${libsaneUDevRuleNumber}-brother-libsane-type1.rules
    chmod 644 $out/etc/udev/rules.d/${libsaneUDevRuleNumber}-brother-libsane-type1.rules
  '';

  dontStrip = true;
  dontPatchELF = true;

  meta = {
    description = "Brother type1 scanners udev rules";
    homepage = http://www.brother.com;
    platforms = stdenv.lib.platforms.linux;
    license = stdenv.lib.licenses.unfree;
    maintainers = with stdenv.lib.maintainers; [ jraygauthier ];
  };
}