1{
2 lib,
3 buildGoModule,
4 stdenv,
5 fetchFromGitHub,
6 installShellFiles,
7 asciidoc,
8 databasePath ? "/etc/secureboot",
9 nix-update-script,
10}:
11
12buildGoModule rec {
13 pname = "sbctl";
14 version = "0.17";
15
16 src = fetchFromGitHub {
17 owner = "Foxboron";
18 repo = "sbctl";
19 tag = version;
20 hash = "sha256-7dCaWemkus2GHxILBEx5YvzdAmv89JfcPbqZZ6QwriI";
21 };
22
23 vendorHash = "sha256-gpHEJIbLnB0OiYB00rHK6OwrnHTHCj/tTVlUzuFjFKY=";
24
25 ldflags = [
26 "-s"
27 "-w"
28 "-X github.com/foxboron/sbctl.DatabasePath=${databasePath}"
29 "-X github.com/foxboron/sbctl.Version=${version}"
30 ];
31
32 nativeBuildInputs = [
33 installShellFiles
34 asciidoc
35 ];
36
37 postBuild = ''
38 make docs/sbctl.conf.5 docs/sbctl.8
39 '';
40
41 checkFlags = [
42 # https://github.com/Foxboron/sbctl/issues/343
43 "-skip"
44 "github.com/google/go-tpm-tools/.*"
45 ];
46
47 postInstall = ''
48 installManPage docs/sbctl.conf.5 docs/sbctl.8
49 ''
50 + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
51 installShellCompletion --cmd sbctl \
52 --bash <($out/bin/sbctl completion bash) \
53 --fish <($out/bin/sbctl completion fish) \
54 --zsh <($out/bin/sbctl completion zsh)
55 '';
56
57 passthru.updateScript = nix-update-script { };
58
59 meta = {
60 description = "Secure Boot key manager";
61 mainProgram = "sbctl";
62 homepage = "https://github.com/Foxboron/sbctl";
63 license = lib.licenses.mit;
64 maintainers = with lib.maintainers; [
65 Pokeylooted
66 raitobezarius
67 Scrumplex
68 ];
69 # go-uefi does not support darwin at the moment:
70 # see upstream on https://github.com/Foxboron/go-uefi/issues/13
71 platforms = lib.platforms.linux;
72 };
73}