lol
1{ lib
2, buildGoModule
3, buildGo120Module
4, buildGo121Module
5, fetchFromGitHub
6, nixosTests
7, installShellFiles
8}:
9
10let
11 generic =
12 { buildGoModule, version, sha256, vendorHash, ... }@attrs:
13 let attrs' = builtins.removeAttrs attrs [ "buildGoModule" "version" "sha256" "vendorHash" ];
14 in
15 buildGoModule (rec {
16 pname = "nomad";
17 inherit version vendorHash;
18
19 subPackages = [ "." ];
20
21 src = fetchFromGitHub {
22 owner = "hashicorp";
23 repo = pname;
24 rev = "v${version}";
25 inherit sha256;
26 };
27
28 nativeBuildInputs = [ installShellFiles ];
29
30 # ui:
31 # Nomad release commits include the compiled version of the UI, but the file
32 # is only included if we build with the ui tag.
33 tags = [ "ui" ];
34
35 postInstall = ''
36 echo "complete -C $out/bin/nomad nomad" > nomad.bash
37 installShellCompletion nomad.bash
38 '';
39
40 meta = with lib; {
41 homepage = "https://www.nomadproject.io/";
42 description = "A Distributed, Highly Available, Datacenter-Aware Scheduler";
43 license = licenses.mpl20;
44 maintainers = with maintainers; [ rushmorem pradeepchhetri endocrimes amaxine techknowlogick ];
45 };
46 } // attrs');
47in
48rec {
49 # Nomad never updates major go versions within a release series and is unsupported
50 # on Go versions that it did not ship with. Due to historic bugs when compiled
51 # with different versions we pin Go for all versions.
52 # Upstream partially documents used Go versions here
53 # https://github.com/hashicorp/nomad/blob/master/contributing/golang.md
54
55 nomad = nomad_1_5;
56
57 nomad_1_4 = generic {
58 buildGoModule = buildGo120Module;
59 version = "1.4.12";
60 sha256 = "sha256-dO98FOaO5MB5pWzeF705s/aBDTaF0OyWnVxWGB91suI=";
61 vendorHash = "sha256-D5TcTZa64Jr47u4mrTXK4lUIC5gfBQNVgL6QKh1CaQM=";
62 passthru.tests.nomad = nixosTests.nomad;
63 };
64
65 nomad_1_5 = generic {
66 buildGoModule = buildGo120Module;
67 version = "1.5.8";
68 sha256 = "sha256-5VAUNunQz4s1Icd+s5i8Kx6u1P0By+ikl4C5wXM1oho=";
69 vendorHash = "sha256-y3WiQuoQn6SdwTgtPWuB6EBtsJC+YleQPzownZQNkno=";
70 passthru.tests.nomad = nixosTests.nomad;
71 preCheck = ''
72 export PATH="$PATH:$NIX_BUILD_TOP/go/bin"
73 '';
74 };
75
76 nomad_1_6 = generic {
77 buildGoModule = buildGo121Module;
78 version = "1.6.3";
79 sha256 = "sha256-5UWGriDy15PX3+9UppcUsEwih/e9COLVBis3fn+24L0=";
80 vendorHash = "sha256-gXoheW6Ww9Iu4utKNHweP2blzhWid+Q9Tp0ZgCmBAVg=";
81 passthru.tests.nomad = nixosTests.nomad;
82 preCheck = ''
83 export PATH="$PATH:$NIX_BUILD_TOP/go/bin"
84 '';
85 };
86}