lol
1{ stdenv, fetchgit, fetchurl, trousers, leveldb, unzip, scons, pkgconfig
2, glib, dbus_cplusplus, dbus, protobuf, openssl, snappy, pam }:
3
4let
5 src_chromebase = fetchgit {
6 url = "https://chromium.googlesource.com/chromium/src/base.git";
7 rev = "2dfe404711e15e24e79799516400c61b2719d7af";
8 sha256 = "2bd93a3ace4b6767db2c1bd1e16f426c97b8d2133a9cb15f8372b2516cfa65c5";
9 };
10
11 src_gmock = fetchurl {
12 url = "https://googlemock.googlecode.com/files/gmock-1.7.0.zip";
13 sha256 = "0nq98cpnv2jsx2byp4ilam6kydcnziflkc16ikydajmp4mcvpz16";
14 };
15
16 src_platform2 = fetchgit {
17 url = "https://chromium.googlesource.com/chromiumos/platform2";
18 rev = "e999e989eaa71c3db7314fc7b4e20829b2b5473b";
19 sha256 = "bb43ef7918ec6219711cbba3ce91236413738f1341261a1845256b3d6cc9f843";
20 };
21
22in
23
24stdenv.mkDerivation rec {
25 name = "chaps-0.42-6812";
26 version = "0.42-6812";
27
28 src = fetchgit {
29 url = "https://github.com/google/chaps-linux";
30 rev = "989aadc45cdb216ca35b0c97d13fc691576fa1d7";
31 sha256 = "c58e08e89d36050cd831116819d555f0e24e7bf11047cb18f2a2eead45ba67be";
32 };
33
34 patches = [ ./fix_absolute_path.patch ./fix_environment_variables.patch ./fix_scons.patch ./insert_prefetches.patch ];
35
36 postPatch = ''
37 substituteInPlace makefile --replace @@NIXOS_SRC_CHROMEBASE@@ ${src_chromebase}
38 substituteInPlace makefile --replace @@NIXOS_SRC_GMOCK@@ ${src_gmock}
39 substituteInPlace makefile --replace @@NIXOS_SRC_PLATFORM2@@ ${src_platform2}
40 substituteInPlace makefile --replace @@NIXOS_LEVELDB@@ ${leveldb}
41 '';
42
43 nativeBuildInputs = [ unzip scons pkgconfig ];
44
45 buildInputs = [ trousers glib dbus_cplusplus dbus protobuf openssl snappy leveldb pam ];
46
47 buildPhase = ''
48 make build
49 '';
50
51 installPhase = ''
52 mkdir -p $out/bin
53 cp ${name}/out/chapsd $out/bin/.
54 cp ${name}/out/chaps_client $out/bin/.
55
56 mkdir -p $out/lib
57 cp ${name}/out/libchaps.so.* $out/lib/.
58 mkdir -p $out/lib/security
59 cp ${name}/out/pam_chaps.so $out/lib/security/.
60
61 mkdir -p $out/include
62 cp -r ${name}/out/chaps $out/include/.
63
64 mkdir -p $out/etc/dbus-1/system.d
65 cp ${name}/out/org.chromium.Chaps.conf $out/etc/dbus-1/system.d/.
66 mkdir -p $out/etc/dbus-1/system-services
67 cp ${name}/platform2/chaps/org.chromium.Chaps.service $out/etc/dbus-1/system-services/.
68
69 mkdir -p $out/usr/share/pam-configs/chaps
70 mkdir -p $out/usr/share/man/man8
71 cp ${name}/man/* $out/usr/share/man/man8/.
72 '';
73
74 meta = with stdenv.lib; {
75 description = "PKCS #11 implementation based on trusted platform module (TPM)";
76 homepage = "https://www.chromium.org/developers/design-documents/chaps-technical-design";
77 maintainers = [ maintainers.tstrobel ];
78 platforms = [ "x86_64-linux" ];
79 license = licenses.bsd3;
80 };
81}