nixpkgs/pkgs/applications/virtualization/colima/default.nix
2022-10-09 07:20:35 +00:00

64 lines
1.5 KiB
Nix

{ lib
, buildGoModule
, fetchFromGitHub
, installShellFiles
, lima
, makeWrapper
, qemu
, testers
, colima
}:
buildGoModule rec {
pname = "colima";
version = "0.4.6";
src = fetchFromGitHub {
owner = "abiosoft";
repo = pname;
rev = "v${version}";
sha256 = "sha256-mVEp/4iL23rrw6HSl/7qMGK4YCJ6I+9gcSIhyPsAWzc=";
# We need the git revision
leaveDotGit = true;
postFetch = ''
git -C $out rev-parse --short HEAD > $out/.git-revision
rm -rf $out/.git
'';
};
nativeBuildInputs = [ installShellFiles makeWrapper ];
vendorSha256 = "sha256-tsMQMWEkTE1NhevcqBETGWiboqL6QTepgnIo4B5Y4wQ=";
CGO_ENABLED = 1;
preConfigure = ''
ldflags="-s -w -X github.com/abiosoft/colima/config.appVersion=${version} \
-X github.com/abiosoft/colima/config.revision=$(cat .git-revision)"
'';
subPackages = [ "cmd/colima" ];
postInstall = ''
wrapProgram $out/bin/colima \
--prefix PATH : ${lib.makeBinPath [ lima qemu ]}
installShellCompletion --cmd colima \
--bash <($out/bin/colima completion bash) \
--fish <($out/bin/colima completion fish) \
--zsh <($out/bin/colima completion zsh)
'';
passthru.tests.version = testers.testVersion {
package = colima;
command = "HOME=$(mktemp -d) colima version";
};
meta = with lib; {
description = "Container runtimes with minimal setup";
homepage = "https://github.com/abiosoft/colima";
license = licenses.mit;
maintainers = with maintainers; [ aaschmid tricktron ];
};
}