about summary refs log tree commit diff
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2016-02-08 15:07:06 +0100
committerProfpatsch <mail@profpatsch.de>2016-02-08 15:07:06 +0100
commit890e08ad31e5429569ed9a502bc638836df9d05b (patch)
tree151a9a49232a671ac4f00319169141857fb51158
parent58a526010ce3c8e8c9183cf14fead8fa4fe32418 (diff)
profpatsch: sane experiment
-rw-r--r--machines/default.nix1
-rw-r--r--machines/profpatsch/experiments.nix9
-rw-r--r--machines/profpatsch/katara.nix2
-rw-r--r--machines/profpatsch/tmp/sane/backends/default.nix13
-rw-r--r--machines/profpatsch/tmp/sane/backends/generic.nix76
5 files changed, 100 insertions, 1 deletions
diff --git a/machines/default.nix b/machines/default.nix
index 7c0ed379..32fd53b0 100644
--- a/machines/default.nix
+++ b/machines/default.nix
@@ -21,6 +21,7 @@ in {
   };
   profpatsch = {
     katara = callMachine ./profpatsch/katara.nix {};
+    experiments = callMachine ./profpatsch/experiments.nix {};
   };
   misc = {
     mailserver = callMachine ./misc/mailserver.nix {};
diff --git a/machines/profpatsch/experiments.nix b/machines/profpatsch/experiments.nix
new file mode 100644
index 00000000..0264747e
--- /dev/null
+++ b/machines/profpatsch/experiments.nix
@@ -0,0 +1,9 @@
+{ config, lib, pkgs, ...}:
+
+{
+  nixpkgs.config.packageOverrides = pkgs: {
+    sane-backends = pkgs.callPackage ./tmp/sane/backends {};
+  };
+
+  hardware.sane.enable = true;
+}
diff --git a/machines/profpatsch/katara.nix b/machines/profpatsch/katara.nix
index 3ae65449..00cbe88b 100644
--- a/machines/profpatsch/katara.nix
+++ b/machines/profpatsch/katara.nix
@@ -26,7 +26,7 @@ in {
     fileSystems."/" = {
       device = "/dev/dm-0";
       fsType = "btrfs";
-      options = "ssd";
+      options = [ "ssd" ];
     };
 
     fileSystems."/boot" = {
diff --git a/machines/profpatsch/tmp/sane/backends/default.nix b/machines/profpatsch/tmp/sane/backends/default.nix
new file mode 100644
index 00000000..a3ca7fdd
--- /dev/null
+++ b/machines/profpatsch/tmp/sane/backends/default.nix
@@ -0,0 +1,13 @@
+{ callPackage, fetchurl, ... } @ args:
+
+callPackage ./generic.nix (args // rec {
+  version = "1.0.25";
+  src = fetchurl {
+    sha256 = "0b3fvhrxl4l82bf3v0j47ypjv6a0k5lqbgknrq1agpmjca6vmmx4";
+    urls = [
+      "http://pkgs.fedoraproject.org/repo/pkgs/sane-backends/sane-backends-${version}.tar.gz/f9ed5405b3c12f07c6ca51ee60225fe7/sane-backends-${version}.tar.gz"
+      "https://alioth.debian.org/frs/download.php/file/4146/sane-backends-${version}.tar.gz"
+    ];
+    curlOpts = "--insecure";
+  };
+})
diff --git a/machines/profpatsch/tmp/sane/backends/generic.nix b/machines/profpatsch/tmp/sane/backends/generic.nix
new file mode 100644
index 00000000..e457ba29
--- /dev/null
+++ b/machines/profpatsch/tmp/sane/backends/generic.nix
@@ -0,0 +1,76 @@
+{ stdenv, fetchurl
+, avahi, libjpeg, libusb1, libv4l, net_snmp
+, gettext, pkgconfig
+
+# List of { src name backend } attibute sets - see installFirmware below:
+, extraFirmware ? []
+
+# For backwards compatibility with older setups; use extraFirmware instead:
+, gt68xxFirmware ? null, snapscanFirmware ? null
+
+# Passed from versioned package (e.g. default.nix, git.nix):
+, version, src, ...
+}:
+
+stdenv.mkDerivation {
+  inherit src version;
+
+  name = "sane-backends-${version}";
+
+  outputs = [ "out" "doc" "man" ];
+
+  configureFlags = []
+    ++ stdenv.lib.optional (avahi != null) "--enable-avahi"
+    ++ stdenv.lib.optional (libusb1 != null) "--enable-libusb_1_0"
+    ;
+
+  buildInputs = [ avahi libusb1 libv4l net_snmp ];
+  nativeBuildInputs = [ gettext pkgconfig ];
+
+  postInstall = let
+
+    compatFirmware = extraFirmware
+      ++ stdenv.lib.optional (gt68xxFirmware != null) {
+        src = gt68xxFirmware.fw;
+        inherit (gt68xxFirmware) name;
+        backend = "gt68xx";
+      }
+      ++ stdenv.lib.optional (snapscanFirmware != null) {
+        src = snapscanFirmware;
+        name = "your-firmwarefile.bin";
+        backend = "snapscan";
+      };
+
+    installFirmware = f: ''
+      mkdir -p $out/share/sane/${f.backend}
+      ln -sv ${f.src} $out/share/sane/${f.backend}/${f.name}
+    '';
+
+  in ''
+    mkdir -p $out/etc/udev/rules.d/
+    ./tools/sane-desc -m udev > $out/etc/udev/rules.d/49-libsane.rules || \
+    cp tools/udev/libsane.rules $out/etc/udev/rules.d/49-libsane.rules
+    # the created 49-libsane references /bin/sh
+    substituteInPlace $out/etc/udev/rules.d/49-libsane.rules \
+      --replace "RUN+=\"/bin/sh" "RUN+=\"${stdenv.shell}"
+
+    substituteInPlace $out/lib/libsane.la \
+      --replace "-ljpeg" "-L${libjpeg}/lib -ljpeg"
+  '' + stdenv.lib.concatStrings (builtins.map installFirmware compatFirmware);
+
+  meta = with stdenv.lib; {
+    description = "SANE (Scanner Access Now Easy) backends";
+    longDescription = ''
+      Collection of open-source SANE backends (device drivers).
+      SANE is a universal scanner interface providing standardized access to
+      any raster image scanner hardware: flatbed scanners, hand-held scanners,
+      video- and still-cameras, frame-grabbers, etc. For a list of supported
+      scanners, see http://www.sane-project.org/sane-backends.html.
+    '';
+    homepage = "http://www.sane-project.org/";
+    license = licenses.gpl2Plus;
+
+    maintainers = with maintainers; [ nckx simons ];
+    platforms = platforms.linux;
+  };
+}