1{ lib
2, buildGoModule
3, fetchFromGitHub
4, coreutils
5, cryptsetup
6, mount
7, systemd
8, umount
9}:
10
11buildGoModule rec {
12 pname = "interlock";
13 version = "2020.03.05";
14
15 src = fetchFromGitHub {
16 owner = "usbarmory";
17 repo = "interlock";
18 rev = "v${version}";
19 sha256 = "sha256-YXa4vErt3YnomTKAXCv8yUVhcc0ST47n9waW5E8QZzY=";
20 };
21
22 vendorSha256 = "sha256-OL6I95IpyTIc8wCwD9nWxVUTrmZH6COhsd/YwNTyvN0=";
23
24 ldflags = [ "-s" "-w" ];
25
26 postPatch = ''
27 grep -lr '/s\?bin/' | xargs sed -i \
28 -e 's|/bin/mount|${mount}/bin/mount|' \
29 -e 's|/bin/umount|${umount}/bin/umount|' \
30 -e 's|/bin/cp|${coreutils}/bin/cp|' \
31 -e 's|/bin/mv|${coreutils}/bin/mv|' \
32 -e 's|/bin/chown|${coreutils}/bin/chown|' \
33 -e 's|/bin/date|${coreutils}/bin/date|' \
34 -e 's|/sbin/poweroff|${systemd}/sbin/poweroff|' \
35 -e 's|/usr/bin/sudo|/run/wrappers/bin/sudo|' \
36 -e 's|/sbin/cryptsetup|${cryptsetup}/bin/cryptsetup|'
37 '';
38
39 postInstall = ''
40 mkdir -p $out/share
41 cp -R $src/static $out/share
42 '';
43
44 # Tests are broken due to an error during key generation.
45 doCheck = false;
46
47 meta = with lib; {
48 homepage = "https://github.com/usbarmory/interlock";
49 description = "File encryption tool and an HSM frontend";
50 license = licenses.gpl3Plus;
51 platforms = platforms.linux;
52 };
53}