15 aarch64-darwin = rec {
16 archSuffix = "Darwin-arm64";
17 url = "https://github.com/lima-vm/lima/releases/download/v${version}/lima-${version}-${archSuffix}.tar.gz";
18 sha256 = "271e0224d3e678450424abd4e6766a14ea52b146824bf8cfac7a0f486ceb2a0c";
22 archSuffix = "Darwin-x86_64";
23 url = "https://github.com/lima-vm/lima/releases/download/v${version}/lima-${version}-${archSuffix}.tar.gz";
24 sha256 = "f2d331ef783e0bb00e193efc3d5c9438df5d284b1cbac771e5d239c3459b2b3d";
28 archSuffix = "Linux-aarch64";
29 url = "https://github.com/lima-vm/lima/releases/download/v${version}/lima-${version}-${archSuffix}.tar.gz";
30 sha256 = "8c5c6dc21fae19c5645bf8db8f441aeab7fba21fbe882b2b9db58c126d07846b";
34 archSuffix = "Linux-x86_64";
35 url = "https://github.com/lima-vm/lima/releases/download/v${version}/lima-${version}-${archSuffix}.tar.gz";
36 sha256 = "58e66114ae1e991512a86b6952ab3a1ffe0e12e08199a9a3ea13c3d2f24b307e";
40 stdenvNoCC.mkDerivation {
44 inherit (dist.${stdenvNoCC.hostPlatform.system} or
45 (throw "Unsupported system: ${stdenvNoCC.hostPlatform.system}")) url sha256;
50 nativeBuildInputs = [ makeBinaryWrapper installShellFiles ]
51 ++ lib.optionals stdenvNoCC.hostPlatform.isLinux [ autoPatchelfHook ];
57 chmod +x $out/bin/limactl
58 wrapProgram $out/bin/limactl \
59 --prefix PATH : ${lib.makeBinPath [ qemu ]}
61 # the shell completion only works with a patched $out/bin/limactl and so
62 # needs to run after the autoPatchelfHook is executed in postFixup.
64 installShellCompletion --cmd limactl \
65 --bash <($out/bin/limactl completion bash) \
66 --fish <($out/bin/limactl completion fish) \
67 --zsh <($out/bin/limactl completion zsh)
69 postFixupHooks+=(doShellCompletion)
74 doInstallCheck = true;
75 installCheckPhase = ''
76 USER=nix $out/bin/limactl validate $out/share/lima/examples/default.yaml
77 USER=nix $out/bin/limactl validate $out/share/lima/examples/experimental/vz.yaml
80 # Stripping removes entitlements of the binary on Darwin making it non-operational.
81 # Therefore, disable stripping on Darwin.
82 dontStrip = stdenvNoCC.hostPlatform.isDarwin;
84 passthru.updateScript =
86 lima-bin = builtins.toString ./bin.nix;
88 writeScript "update-lima-bin.sh" ''
89 #!/usr/bin/env nix-shell
90 #!nix-shell -i bash -p common-updater-scripts curl jq gawk
94 LATEST_VERSION=$(curl -H "Accept: application/vnd.github+json" -Ls https://api.github.com/repos/lima-vm/lima/releases/latest | jq -r .tag_name | cut -c 2-)
95 curl -Ls -o SHA256SUMS https://github.com/lima-vm/lima/releases/download/v$LATEST_VERSION/SHA256SUMS
96 AARCH64_DARWIN_SHA256=$(cat SHA256SUMS | awk '/Darwin-arm64/{print $1}')
97 X86_64_DARWIN_SHA256=$(cat SHA256SUMS | awk '/Darwin-x86_64/{print $1}')
98 AARCH64_LINUX_SHA256=$(cat SHA256SUMS | awk '/Linux-aarch64/{print $1}')
99 X86_64_LINUX_SHA256=$(cat SHA256SUMS | awk '/Linux-x86_64/{print $1}')
101 # reset version first so that all platforms are always updated and in sync
102 update-source-version lima-bin $LATEST_VERSION $AARCH64_DARWIN_SHA256 --file=${lima-bin} --ignore-same-version --system=aarch64-darwin
103 update-source-version lima-bin $LATEST_VERSION $X86_64_DARWIN_SHA256 --file=${lima-bin} --ignore-same-version --system=x86_64-darwin
104 update-source-version lima-bin $LATEST_VERSION $AARCH64_LINUX_SHA256 --file=${lima-bin} --ignore-same-version --system=aarch64-linux
105 update-source-version lima-bin $LATEST_VERSION $X86_64_LINUX_SHA256 --file=${lima-bin} --ignore-same-version --system=x86_64-linux
110 homepage = "https://github.com/lima-vm/lima";
111 description = "Linux virtual machines (on macOS, in most cases)";
112 license = licenses.asl20;
113 maintainers = with maintainers; [ tricktron ];
114 platforms = platforms.linux ++ platforms.darwin;