2017-09-08 01:21:59 +01:00
|
|
|
{ stdenv, buildGoPackage, fetchFromGitHub, fetchurl, go-bindata, kubernetes, libvirt, qemu, docker-machine-kvm,
|
2017-11-19 15:17:40 +00:00
|
|
|
gpgme, makeWrapper, hostPlatform, vmnet }:
|
2017-01-31 17:39:24 +00:00
|
|
|
|
2016-12-06 01:23:59 +00:00
|
|
|
let
|
2017-03-12 01:12:53 +00:00
|
|
|
binPath = [ kubernetes ]
|
|
|
|
++ stdenv.lib.optionals stdenv.isLinux [ libvirt qemu docker-machine-kvm ]
|
|
|
|
++ stdenv.lib.optionals stdenv.isDarwin [];
|
2017-01-31 17:39:24 +00:00
|
|
|
|
2017-03-12 01:12:53 +00:00
|
|
|
# Normally, minikube bundles localkube in its own binary via go-bindata. Unfortunately, it needs to make that localkube
|
|
|
|
# a static linux binary, and our Linux nixpkgs go compiler doesn't seem to work when asking for a cgo binary that's static
|
|
|
|
# (presumably because we don't have some static system libraries it wants), and cross-compiling cgo on Darwin is a nightmare.
|
|
|
|
#
|
|
|
|
# Note that minikube can download (and cache) versions of localkube it needs on demand. Unfortunately, minikube's knowledge
|
2017-04-08 23:13:48 +01:00
|
|
|
# of where it can download versions of localkube seems to rely on a json file that doesn't get updated as often as we'd like. So
|
2017-03-12 01:12:53 +00:00
|
|
|
# instead, we download localkube ourselves and shove it into the minikube binary. The versions URL that minikube uses is
|
2017-04-08 23:13:48 +01:00
|
|
|
# currently https://storage.googleapis.com/minikube/k8s_releases.json
|
|
|
|
|
2017-10-27 15:13:03 +01:00
|
|
|
localkube-version = "1.8.0";
|
2017-03-12 01:12:53 +00:00
|
|
|
localkube-binary = fetchurl {
|
2017-04-08 23:13:48 +01:00
|
|
|
url = "https://storage.googleapis.com/minikube/k8sReleases/v${localkube-version}/localkube-linux-amd64";
|
2017-10-27 15:13:03 +01:00
|
|
|
sha256 = "09mv1g9i0d14brvvp2wxgmfqvgp0na5dbm4z76a660q1fxszvgqc";
|
2017-03-12 01:12:53 +00:00
|
|
|
};
|
|
|
|
in buildGoPackage rec {
|
|
|
|
pname = "minikube";
|
|
|
|
name = "${pname}-${version}";
|
2017-12-13 17:19:32 +00:00
|
|
|
version = "0.24.1";
|
2016-12-06 01:23:59 +00:00
|
|
|
|
2017-03-12 01:12:53 +00:00
|
|
|
goPackagePath = "k8s.io/minikube";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "kubernetes";
|
|
|
|
repo = "minikube";
|
|
|
|
rev = "v${version}";
|
2017-12-13 17:19:32 +00:00
|
|
|
sha256 = "18b5ic4lcn84hq2ji5alyx58x9vi0b03544i5xzfgn3h2k78kynk";
|
2016-12-06 01:23:59 +00:00
|
|
|
};
|
|
|
|
|
2017-11-14 13:39:19 +00:00
|
|
|
patches = [
|
|
|
|
./localkube.patch
|
|
|
|
];
|
|
|
|
|
2017-03-12 01:12:53 +00:00
|
|
|
# kubernetes is here only to shut up a loud warning when generating the completions below. minikube checks very eagerly
|
|
|
|
# that kubectl is on the $PATH, even if it doesn't use it at all to generate the completions
|
2017-11-19 15:17:40 +00:00
|
|
|
buildInputs = [ go-bindata makeWrapper kubernetes gpgme ] ++ stdenv.lib.optional hostPlatform.isDarwin vmnet;
|
2017-03-12 01:12:53 +00:00
|
|
|
subPackages = [ "cmd/minikube" ];
|
2016-12-06 01:23:59 +00:00
|
|
|
|
2017-03-12 01:12:53 +00:00
|
|
|
preBuild = ''
|
|
|
|
pushd go/src/${goPackagePath} >/dev/null
|
2016-12-06 01:23:59 +00:00
|
|
|
|
2017-03-12 01:12:53 +00:00
|
|
|
mkdir -p out
|
|
|
|
cp ${localkube-binary} out/localkube
|
2016-12-06 01:23:59 +00:00
|
|
|
|
2017-03-12 01:12:53 +00:00
|
|
|
go-bindata -nomemcopy -o pkg/minikube/assets/assets.go -pkg assets ./out/localkube deploy/addons/...
|
2017-03-05 03:23:44 +00:00
|
|
|
|
2017-03-12 01:12:53 +00:00
|
|
|
ISO_VERSION=$(grep "^ISO_VERSION" Makefile | sed "s/^.*\s//")
|
|
|
|
ISO_BUCKET=$(grep "^ISO_BUCKET" Makefile | sed "s/^.*\s//")
|
2017-01-31 17:39:24 +00:00
|
|
|
|
2017-03-12 01:12:53 +00:00
|
|
|
export buildFlagsArray="-ldflags=\
|
|
|
|
-X k8s.io/minikube/pkg/version.version=v${version} \
|
|
|
|
-X k8s.io/minikube/pkg/version.isoVersion=$ISO_VERSION \
|
|
|
|
-X k8s.io/minikube/pkg/version.isoPath=$ISO_BUCKET"
|
|
|
|
|
|
|
|
popd >/dev/null
|
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $bin/share/bash-completion/completions/
|
|
|
|
MINIKUBE_WANTUPDATENOTIFICATION=false HOME=$PWD $bin/bin/minikube completion bash > $bin/share/bash-completion/completions/minikube
|
2016-12-06 01:23:59 +00:00
|
|
|
'';
|
|
|
|
|
2017-03-12 01:12:53 +00:00
|
|
|
postFixup = "wrapProgram $bin/bin/${pname} --prefix PATH : ${stdenv.lib.makeBinPath binPath}";
|
|
|
|
|
2016-12-06 01:23:59 +00:00
|
|
|
meta = with stdenv.lib; {
|
2017-03-12 01:12:53 +00:00
|
|
|
homepage = https://github.com/kubernetes/minikube;
|
2016-12-06 01:23:59 +00:00
|
|
|
description = "A tool that makes it easy to run Kubernetes locally";
|
2017-03-12 01:12:53 +00:00
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ ebzzry copumpkin ];
|
|
|
|
platforms = with platforms; unix;
|
2016-12-06 01:23:59 +00:00
|
|
|
};
|
|
|
|
}
|