diff --git a/modules/vfs495.nix b/modules/vfs495.nix new file mode 100644 index 0000000..6d884cc --- /dev/null +++ b/modules/vfs495.nix @@ -0,0 +1,39 @@ +{ pkgs, config, lib, ... }: + +let +vfs495 = pkgs.callPackage ../packages/vfs495.nix { }; +cfg = config.services.vfs495; +in +{ + options.services.vfs495 = with lib; { + enable = mkOption { type = types.bool; default = false; }; + }; + config = lib.mkIf cfg.enable { + nixpkgs.config = { + packageOverrides = pkgs : { + libfprint = pkgs.libfprint.overrideDerivation (attrs: { + patches = [(pkgs.fetchurl { + url = "http://ix.io/1eh0"; + sha256 = "1h55gc07piidixxm5h37p0514h67q0z1q9ygapyl89in3csd5n94"; + })]; + buildInputs = [pkgs.autoreconfHook] ++ attrs.buildInputs; + }); + }; + }; + services.fprintd.enable = true; + systemd.services.fprintd = { + path = [pkgs.procps]; + environment.LD_LIBRARY_PATH = "${vfs495}/usr/lib"; + }; + systemd.services.vfs495 = { + serviceConfig = { + Type = "forking"; + ExecStartPre = "rm -f /tmp/vcsSemKey_*"; + ExecStart = "${vfs495}/usr/bin/vcsFPService"; + }; + wantedBy = [ "multi-user.target" ]; + before = ["fprintd.service"]; + }; + # TODO: send SIGUSR1 on suspend and SIGUSR2 on resume + }; +} diff --git a/packages/vfs495.nix b/packages/vfs495.nix new file mode 100644 index 0000000..bd59836 --- /dev/null +++ b/packages/vfs495.nix @@ -0,0 +1,39 @@ +{ pkgs ? import {} }: with pkgs; +let +# this is ugly but it works +openssl_0_9_8 = runCommand "openssl_0_9_8" {} '' + mkdir -p $out/lib/ + ln -s ${openssl_1_0_1.out}/lib/libcrypto.so $out/lib/libcrypto.so.0.9.8 + ln -s ${openssl_1_0_1.out}/lib/libssl.so $out/lib/libssl.so.0.9.8 +''; +in +stdenv.mkDerivation rec { + version = "4.5-118.00"; + name = "vfs495-${version}"; + + src = fetchurl { + url = "https://dl.dropboxusercontent.com/u/71679/Validity-Sensor-Setup-${version}.x86_64.rpm"; + sha256 = "1hd03bv14zr639l0wnwcc0bggjsfpnq57fjz3vqym19xqn9ks001"; + }; + nativeBuildInputs = [ patchelf ]; + buildInputs = [libusb libusb1 openssl_0_9_8]; + unpackCmd = '' + (mkdir -p "${name}" && cd "${name}" && + ${rpmextract}/bin/rpmextract "$curSrc")''; + installPhase = '' + mkdir -p $out + cp -R etc/ usr/ $out/ + patchelf \ + --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "${lib.makeLibraryPath buildInputs}" \ + $out/usr/bin/vcsFPService + patchelf --set-rpath "${lib.makeLibraryPath buildInputs}" \ + $out/usr/lib/libvfsFprintWrapper.so + ''; + meta = with stdenv.lib; { + description = "Userspace driver for VFS495 fingerprint readers"; + license = licenses.unfreeRedistributable; + #maintainers = with maintainers; [ yorickvp ]; + platforms = platforms.linux; + }; +}