nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 darwin,
5 buildGoModule,
6 fetchFromGitHub,
7 installShellFiles,
8 lima,
9 makeWrapper,
10 procps,
11 qemu,
12 testers,
13 colima,
14}:
15
16buildGoModule rec {
17 pname = "colima";
18 version = "0.9.1";
19
20 src = fetchFromGitHub {
21 owner = "abiosoft";
22 repo = "colima";
23 tag = "v${version}";
24 hash = "sha256-oRhpABYyP4T6kfmvJ4llPXcXWrSbxU7uUfvXQhm2huc=";
25 # We need the git revision
26 leaveDotGit = true;
27 postFetch = ''
28 git -C $out rev-parse --short HEAD > $out/.git-revision
29 rm -rf $out/.git
30 '';
31 };
32
33 nativeBuildInputs = [
34 installShellFiles
35 makeWrapper
36 ]
37 ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.DarwinTools ];
38
39 vendorHash = "sha256-ZwgzKCOEhgKK2LNRLjnWP6qHI4f6OGORvt3CREJf55I=";
40
41 # disable flaky Test_extractZones
42 # https://hydra.nixos.org/build/212378003/log
43 excludedPackages = "gvproxy";
44
45 env.CGO_ENABLED = 1;
46
47 postPatch = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
48 substituteInPlace cmd/daemon/daemon.go \
49 --replace-fail '/usr/bin/pkill' '${lib.getExe' procps "pkill"}'
50
51 substituteInPlace daemon/process/vmnet/vmnet.go \
52 --replace-fail '/usr/bin/pkill' '${lib.getExe' procps "pkill"}'
53 '';
54
55 preConfigure = ''
56 ldflags="-s -w -X github.com/abiosoft/colima/config.appVersion=${version} \
57 -X github.com/abiosoft/colima/config.revision=$(cat .git-revision)"
58 '';
59
60 postInstall = ''
61 wrapProgram $out/bin/colima \
62 --prefix PATH : ${
63 lib.makeBinPath [
64 # Suppress warning on `colima start`: https://github.com/abiosoft/colima/issues/1333
65 (lima.override {
66 withAdditionalGuestAgents = true;
67 })
68 qemu
69 ]
70 }
71
72 installShellCompletion --cmd colima \
73 --bash <($out/bin/colima completion bash) \
74 --fish <($out/bin/colima completion fish) \
75 --zsh <($out/bin/colima completion zsh)
76 '';
77
78 passthru.tests.version = testers.testVersion {
79 package = colima;
80 command = "HOME=$(mktemp -d) colima version";
81 };
82
83 meta = {
84 description = "Container runtimes with minimal setup";
85 homepage = "https://github.com/abiosoft/colima";
86 license = lib.licenses.mit;
87 maintainers = with lib.maintainers; [
88 aaschmid
89 tricktron
90 ];
91 mainProgram = "colima";
92 };
93}