3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/applications/networking/cluster/kubernetes/default.nix

99 lines
2.6 KiB
Nix
Raw Normal View History

{ stdenv
, lib
, fetchFromGitHub
, removeReferencesTo
, which
, go
, makeWrapper
, rsync
, installShellFiles
2016-10-10 17:48:00 +01:00
, components ? [
"cmd/kubelet"
"cmd/kube-apiserver"
"cmd/kube-controller-manager"
"cmd/kube-proxy"
2018-03-31 00:16:32 +01:00
"cmd/kube-scheduler"
2017-09-09 00:59:33 +01:00
"test/e2e/e2e.test"
2016-10-10 17:48:00 +01:00
]
}:
2014-11-15 16:18:14 +00:00
stdenv.mkDerivation rec {
pname = "kubernetes";
2021-01-13 12:44:22 +00:00
version = "1.20.4";
2014-11-15 16:18:14 +00:00
src = fetchFromGitHub {
2016-06-06 11:58:51 +01:00
owner = "kubernetes";
2014-11-15 16:18:14 +00:00
repo = "kubernetes";
rev = "v${version}";
2021-01-13 12:44:22 +00:00
sha256 = "0nni351ya688dphdkpyq94p3wjw2kigg85kmalwdpv5wpz1abl5g";
2014-11-15 16:18:14 +00:00
};
nativeBuildInputs = [ removeReferencesTo makeWrapper which go rsync installShellFiles ];
2014-11-15 16:18:14 +00:00
outputs = [ "out" "man" "pause" ];
patches = [ ./fixup-addonmanager-lib-path.patch ];
2016-10-10 17:48:00 +01:00
postPatch = ''
2019-08-09 08:50:49 +01:00
# go env breaks the sandbox
substituteInPlace "hack/lib/golang.sh" \
--replace 'echo "$(go env GOHOSTOS)/$(go env GOHOSTARCH)"' 'echo "${go.GOOS}/${go.GOARCH}"'
2019-04-07 16:01:41 +01:00
substituteInPlace "hack/update-generated-docs.sh" --replace "make" "make SHELL=${stdenv.shell}"
# hack/update-munge-docs.sh only performs some tests on the documentation.
# They broke building k8s; disabled for now.
echo "true" > "hack/update-munge-docs.sh"
2015-04-25 13:18:05 +01:00
patchShebangs ./hack
'';
2014-11-23 00:27:04 +00:00
WHAT = lib.concatStringsSep " " ([
"cmd/kubeadm"
"cmd/kubectl"
] ++ components);
2016-10-10 17:48:00 +01:00
postBuild = ''
2019-04-07 16:01:41 +01:00
./hack/update-generated-docs.sh
2021-01-13 12:44:22 +00:00
(cd build/pause/linux && cc pause.c -o pause)
'';
2016-10-10 17:48:00 +01:00
2014-11-15 16:18:14 +00:00
installPhase = ''
for p in $WHAT; do
install -D _output/local/go/bin/''${p##*/} -t $out/bin
done
2016-10-10 17:48:00 +01:00
2021-01-13 12:44:22 +00:00
install -D build/pause/linux/pause -t $pause/bin
installManPage docs/man/man1/*.[1-9]
2016-12-11 13:56:25 +00:00
# Unfortunately, kube-addons-main.sh only looks for the lib file in either the current working dir
# or in /opt. We have to patch this for now.
substitute cluster/addons/addon-manager/kube-addons-main.sh $out/bin/kube-addons \
--subst-var out
chmod +x $out/bin/kube-addons
2017-09-01 11:08:11 +01:00
patchShebangs $out/bin/kube-addons
wrapProgram $out/bin/kube-addons --set "KUBECTL_BIN" "$out/bin/kubectl"
cp cluster/addons/addon-manager/kube-addons.sh $out/bin/kube-addons-lib.sh
for tool in kubeadm kubectl; do
installShellCompletion --cmd $tool \
--bash <($out/bin/$tool completion bash) \
--zsh <($out/bin/$tool completion zsh)
done
2014-11-15 16:18:14 +00:00
'';
preFixup = ''
2018-12-12 04:30:50 +00:00
find $out/bin $pause/bin -type f -exec remove-references-to -t ${go} '{}' +
2014-11-15 16:18:14 +00:00
'';
meta = with lib; {
2016-06-06 11:58:51 +01:00
description = "Production-Grade Container Scheduling and Management";
2014-11-15 16:18:14 +00:00
license = licenses.asl20;
2020-04-01 14:59:46 +01:00
homepage = "https://kubernetes.io";
maintainers = with maintainers; [ johanot offline saschagrunert ];
platforms = platforms.unix;
2014-11-15 16:18:14 +00:00
};
}