nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildGoModule,
4 buildGo124Module,
5 fetchFromGitHub,
6 nixosTests,
7 installShellFiles,
8}:
9
10let
11 generic =
12 {
13 buildGoModule,
14 version,
15 hash,
16 vendorHash,
17 license,
18 ...
19 }@attrs:
20 let
21 attrs' = builtins.removeAttrs attrs [
22 "buildGoModule"
23 "version"
24 "hash"
25 "vendorHash"
26 "license"
27 ];
28 in
29 buildGoModule (
30 rec {
31 pname = "nomad";
32 inherit version vendorHash;
33
34 subPackages = [ "." ];
35
36 src = fetchFromGitHub {
37 owner = "hashicorp";
38 repo = pname;
39 rev = "v${version}";
40 inherit hash;
41 };
42
43 # Nomad requires Go 1.24.4, but nixpkgs doesn't have it in unstable yet.
44 postPatch = ''
45 substituteInPlace go.mod \
46 --replace-warn "go 1.24.4" "go 1.24.3"
47 '';
48
49 nativeBuildInputs = [ installShellFiles ];
50
51 ldflags = [
52 "-X github.com/hashicorp/nomad/version.Version=${version}"
53 "-X github.com/hashicorp/nomad/version.VersionPrerelease="
54 "-X github.com/hashicorp/nomad/version.BuildDate=1970-01-01T00:00:00Z"
55 ];
56
57 # ui:
58 # Nomad release commits include the compiled version of the UI, but the file
59 # is only included if we build with the ui tag.
60 tags = [ "ui" ];
61
62 postInstall = ''
63 echo "complete -C $out/bin/nomad nomad" > nomad.bash
64 installShellCompletion nomad.bash
65 '';
66
67 meta = with lib; {
68 homepage = "https://developer.hashicorp.com/nomad";
69 description = "Distributed, Highly Available, Datacenter-Aware Scheduler";
70 mainProgram = "nomad";
71 inherit license;
72 maintainers = with maintainers; [
73 rushmorem
74 pradeepchhetri
75 techknowlogick
76 cottand
77 ];
78 };
79 }
80 // attrs'
81 );
82in
83rec {
84 # Nomad never updates major go versions within a release series and is unsupported
85 # on Go versions that it did not ship with. Due to historic bugs when compiled
86 # with different versions we pin Go for all versions.
87 # Upstream partially documents used Go versions here
88 # https://github.com/hashicorp/nomad/blob/master/contributing/golang.md
89
90 nomad = nomad_1_10;
91
92 nomad_1_10 = generic {
93 buildGoModule = buildGo124Module;
94 version = "1.10.3";
95 hash = "sha256-sDOo7b32H/d5OJ6CRyga1rZZk55bFTi4ynHL/aIH87w=";
96 vendorHash = "sha256-bpCnpeRk329vUd9e6x7iCh+1ouSGd4o4Hq79K0qchJ8=";
97 license = lib.licenses.bsl11;
98 passthru.tests.nomad = nixosTests.nomad;
99 preCheck = ''
100 export PATH="$PATH:$NIX_BUILD_TOP/go/bin"
101 '';
102 };
103
104 nomad_1_9 = generic {
105 buildGoModule = buildGo124Module;
106 version = "1.9.7";
107 hash = "sha256-U02H6DPr1friQ9EwqD/wQnE2Fm20OE5xNccPDJfnsqI=";
108 vendorHash = "sha256-9GnwqkexJAxrhW9yJFaDTdSaZ+p+/dcMuhlusp4cmyw=";
109 license = lib.licenses.bsl11;
110 passthru.tests.nomad = nixosTests.nomad;
111 preCheck = ''
112 export PATH="$PATH:$NIX_BUILD_TOP/go/bin"
113 '';
114 };
115}