btrbk: add mainProgram
[NixPkgs.git] / pkgs / by-name / al / alp / package.nix
blob1f79cd296bf9e0c6367e7bf664fd6fc58d0666ea
1 { lib
2 , buildGoModule
3 , fetchFromGitHub
4 , runCommand
5 , alp
6 }:
8 buildGoModule rec {
9   pname = "alp";
10   version = "1.1.18";
12   src = fetchFromGitHub {
13     owner = "gernotfeichter";
14     repo = "alp";
15     rev = version;
16     hash = "sha256-tE8qKNXLKvFcnDULVkJJ/EJyEsvATCk/3YFkZCmpHSo=";
17   };
18   vendorHash = "sha256-AHPVhtm6La7HWuxJfpxTsS5wFTUZUJoVyebLGYhNKTg=";
20   sourceRoot = "${src.name}/linux";
22   # Executing Go commands directly in checkPhase and buildPhase below,
23   # because the default testsuite runs all go tests, some of which require docker.
24   # Docker is too expensive for https://github.com/NixOS/ofborg.
25   checkPhase = ''
26     runHook preCheck
28     go test -run Test_main_init
30     runHook postCheck
31   '';
33   buildPhase = ''
34     runHook preBuild
36     go build -o $GOPATH/bin/alp main.go
38     runHook postBuild
39   '';
41   passthru.tests = {
42     test-version = runCommand "${pname}-test" {} ''
43       ${alp}/bin/alp version > $out
44       cat $out | grep '${version}'
45     '';
46   };
48   meta = with lib; {
49     description = "Convenient authentication method that lets you use your android device as a key for your Linux machine";
50     homepage = "https://github.com/gernotfeichter/alp";
51     license = licenses.gpl2Only;
52     mainProgram = "alp";
53     maintainers = with maintainers; [ gernotfeichter ];
54   };