1{ config, lib, stdenv, fetchurl
2, bison, flex
3, sysfsutils, kmod, udev
4, firmware ? config.pcmciaUtils.firmware or [] # Special pcmcia cards.
5, configOpts ? config.pcmciaUtils.config or null # Special hardware (map memory & port & irq)
6}: # used to generate postInstall script.
7
8# FIXME: should add an option to choose between hotplug and udev.
9stdenv.mkDerivation rec {
10 pname = "pcmciautils";
11 version = "018";
12
13 src = fetchurl {
14 url = "https://kernel.org/pub/linux/utils/kernel/pcmcia/pcmciautils-${version}.tar.gz";
15 sha256 = "0sfm3w2n73kl5w7gb1m6q8gy5k4rgwvzz79n6yhs9w3sag3ix8sk";
16 };
17
18 buildInputs = [udev bison sysfsutils kmod flex];
19
20 patchPhase = ''
21 sed -i "
22 s,/sbin/modprobe,${kmod}&,;
23 s,/lib/udev/,$out/sbin/,;
24 " udev/* # fix-color */
25 sed -i "
26 s,/lib/firmware,$out&,;
27 s,/etc/pcmcia,$out&,;
28 " src/{startup.c,pcmcia-check-broken-cis.c} # fix-color */
29 ''
30 + (lib.optionalString (firmware == []) ''sed -i "s,STARTUP = true,STARTUP = false," Makefile'')
31 + (lib.optionalString (configOpts != null) "ln -sf ${configOpts} ./config/config.opts")
32 ;
33
34 makeFlags = [ "LEX=flex" ];
35 installFlags = [ "INSTALL=install" "DESTDIR=${placeholder "out"}" ];
36 postInstall =
37 lib.concatMapStrings (path: ''
38 for f in : $(find ${path} -type f); do
39 test "$f" == ":" && continue;
40 mkdir -p $(dirname $out/lib/firmware/$\{f#${path}});
41 ln -s $f $out/lib/firmware/$\{f#${path}};
42 done;
43 '') firmware;
44
45 meta = {
46 homepage = "https://www.kernel.org/pub/linux/utils/kernel/pcmcia/";
47 longDescription = "
48 PCMCIAutils contains the initialization tools necessary to allow
49 the PCMCIA subsystem to behave (almost) as every other
50 hotpluggable bus system.
51 ";
52 license = lib.licenses.gpl2;
53 platforms = lib.platforms.linux;
54 };
55}