1{ lib
2, cni-plugins
3, buildGoModule
4, firecracker
5, containerd
6, runc
7, makeWrapper
8, fetchFromGitHub
9, git
10}:
11
12buildGoModule rec{
13 pname = "ignite";
14 version = "0.10.0";
15
16 src = fetchFromGitHub {
17 owner = "weaveworks";
18 repo = "ignite";
19 rev = "v${version}";
20 sha256 = "sha256-WCgNh+iLtxLslzcHuIwVLZpUEhvBJFe1Y84PaPtbtcY=";
21 leaveDotGit = true;
22 };
23
24 vendorHash = null;
25
26 doCheck = false;
27
28 postPatch = ''
29 # ignite tries to run cni-plugins programs from /opt/cni/bin
30 substituteInPlace pkg/constants/dependencies.go \
31 --replace "/opt/cni/bin/loopback" ${cni-plugins}/bin/loopback \
32 --replace "/opt/cni/bin/bridge" ${cni-plugins}/bin/bridge
33
34 # ignite tries to run cni-plugins programs from /opt/cni/bin
35 substituteInPlace pkg/network/cni/cni.go \
36 --replace "/opt/cni/bin" ${cni-plugins}/bin
37
38 # fetchgit doesn't fetch tags from git repository so it's necessary to force IGNITE_GIT_VERSION to be ${version}
39 # also forcing git state to be clean because if it's dirty ignite will try to fetch the image weaveworks/ignite:dev
40 # which is not in docker.io, we want it to fetch the image weaveworks/ignite:v${version}
41 substituteInPlace hack/ldflags.sh \
42 --replace '$(git describe --tags --abbrev=14 "''${IGNITE_GIT_COMMIT}^{commit}" 2>/dev/null)' "v${version}" \
43 --replace 'IGNITE_GIT_TREE_STATE="dirty"' 'IGNITE_GIT_TREE_STATE="clean"'
44 '';
45
46 nativeBuildInputs = [
47 git
48 makeWrapper
49 ];
50
51 buildInputs = [
52 firecracker
53 ];
54
55 preBuild = ''
56 patchShebangs ./hack/ldflags.sh
57 export buildFlagsArray+=("-ldflags=$(./hack/ldflags.sh)")
58 '';
59
60 postInstall = ''
61 for prog in hack ignite ignited ignite-spawn; do
62 wrapProgram "$out/bin/$prog" --prefix PATH : ${lib.makeBinPath [ cni-plugins firecracker containerd runc ]}
63 done
64 '';
65
66 meta = with lib; {
67 description = "Ignite a Firecracker microVM";
68 homepage = "https://github.com/weaveworks/ignite";
69 license = licenses.asl20;
70 maintainers = with maintainers; [ tfmoraes ];
71 };
72}