1{
2 lib,
3 buildGo123Module,
4 fetchFromGitHub,
5 symlinkJoin,
6 nixosTests,
7 k3s,
8}:
9
10let
11 version = "3.5.21";
12 etcdSrcHash = "sha256-0L/lA9/9SNKMz74R6UPF1I7gj03/e91EpNr4LxKoisw=";
13 etcdServerVendorHash = "sha256-JMxkcDibRcXhU+T7BQMAz95O7xDKefu1YPZK0GU7osk=";
14 etcdUtlVendorHash = "sha256-901QcnEQ8PWnkliqwL4CrbCD+0ja8vJlDke0P4ya8cA=";
15 etcdCtlVendorHash = "sha256-BJ924wRPQTqbqtNtXL3l/OSdQv1UmU1y6Zqu//EWTHI=";
16
17 src = fetchFromGitHub {
18 owner = "etcd-io";
19 repo = "etcd";
20 rev = "v${version}";
21 hash = etcdSrcHash;
22 };
23
24 env = {
25 CGO_ENABLED = 0;
26 };
27
28 meta = with lib; {
29 description = "Distributed reliable key-value store for the most critical data of a distributed system";
30 license = licenses.asl20;
31 homepage = "https://etcd.io/";
32 maintainers = with maintainers; [ offline ];
33 platforms = platforms.darwin ++ platforms.linux;
34 };
35
36 etcdserver = buildGo123Module {
37 pname = "etcdserver";
38
39 inherit
40 env
41 meta
42 src
43 version
44 ;
45
46 vendorHash = etcdServerVendorHash;
47
48 modRoot = "./server";
49
50 preInstall = ''
51 mv $GOPATH/bin/{server,etcd}
52 '';
53
54 # We set the GitSHA to `GitNotFound` to match official build scripts when
55 # git is unavailable. This is to avoid doing a full Git Checkout of etcd.
56 # User facing version numbers are still available in the binary, just not
57 # the sha it was built from.
58 ldflags = [ "-X go.etcd.io/etcd/api/v3/version.GitSHA=GitNotFound" ];
59 };
60
61 etcdutl = buildGo123Module rec {
62 pname = "etcdutl";
63
64 inherit
65 env
66 meta
67 src
68 version
69 ;
70
71 vendorHash = etcdUtlVendorHash;
72
73 modRoot = "./etcdutl";
74 };
75
76 etcdctl = buildGo123Module rec {
77 pname = "etcdctl";
78
79 inherit
80 env
81 meta
82 src
83 version
84 ;
85
86 vendorHash = etcdCtlVendorHash;
87
88 modRoot = "./etcdctl";
89 };
90in
91symlinkJoin {
92 name = "etcd-${version}";
93
94 inherit meta version;
95
96 passthru = {
97 inherit etcdserver etcdutl etcdctl;
98 tests = {
99 inherit (nixosTests) etcd etcd-cluster;
100 k3s = k3s.passthru.tests.etcd;
101 };
102 updateScript = ./update.sh;
103 };
104
105 paths = [
106 etcdserver
107 etcdutl
108 etcdctl
109 ];
110}