summary refs log tree commit diff
path: root/pkgs/applications/networking/cluster/kubernetes/default.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2022-05-31 09:59:33 +0000
committerAlyssa Ross <hi@alyssa.is>2022-05-31 09:59:57 +0000
commit9ff36293d1e428cd7bf03e8d4b03611b6d361c28 (patch)
tree1ab51a42b868c55b83f6ccdb80371b9888739dd9 /pkgs/applications/networking/cluster/kubernetes/default.nix
parent1c4fcd0d4b0541e674ee56ace1053e23e562cc80 (diff)
parentddc3c396a51918043bb0faa6f676abd9562be62c (diff)
downloadnixpkgs-archive.tar
nixpkgs-archive.tar.gz
nixpkgs-archive.tar.bz2
nixpkgs-archive.tar.lz
nixpkgs-archive.tar.xz
nixpkgs-archive.tar.zst
nixpkgs-archive.zip
Last good Nixpkgs for Weston+nouveau? archive
I came this commit hash to terwiz[m] on IRC, who is trying to figure out
what the last version of Spectrum that worked on their NUC with Nvidia
graphics is.
Diffstat (limited to 'pkgs/applications/networking/cluster/kubernetes/default.nix')
-rw-r--r--pkgs/applications/networking/cluster/kubernetes/default.nix104
1 files changed, 104 insertions, 0 deletions
diff --git a/pkgs/applications/networking/cluster/kubernetes/default.nix b/pkgs/applications/networking/cluster/kubernetes/default.nix
new file mode 100644
index 00000000000..e4203f0028a
--- /dev/null
+++ b/pkgs/applications/networking/cluster/kubernetes/default.nix
@@ -0,0 +1,104 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, which
+, go
+, makeWrapper
+, rsync
+, installShellFiles
+, kubectl
+, nixosTests
+
+, components ? [
+    "cmd/kubelet"
+    "cmd/kube-apiserver"
+    "cmd/kube-controller-manager"
+    "cmd/kube-proxy"
+    "cmd/kube-scheduler"
+    "test/e2e/e2e.test"
+  ]
+}:
+
+stdenv.mkDerivation rec {
+  pname = "kubernetes";
+  version = "1.23.5";
+
+  src = fetchFromGitHub {
+    owner = "kubernetes";
+    repo = "kubernetes";
+    rev = "v${version}";
+    sha256 = "sha256-LhJ3gThcsWnawSOmHSzWOG8tfODIPo4dJTMeLKmvMdM=";
+  };
+
+  nativeBuildInputs = [ makeWrapper which go rsync installShellFiles ];
+
+  outputs = [ "out" "man" "pause" ];
+
+  patches = [ ./fixup-addonmanager-lib-path.patch ];
+
+  postPatch = ''
+    # go env breaks the sandbox
+    substituteInPlace "hack/lib/golang.sh" \
+      --replace 'echo "$(go env GOHOSTOS)/$(go env GOHOSTARCH)"' 'echo "${go.GOOS}/${go.GOARCH}"'
+
+    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"
+
+    patchShebangs ./hack
+  '';
+
+  WHAT = lib.concatStringsSep " " ([
+    "cmd/kubeadm"
+  ] ++ components);
+
+  postBuild = ''
+    ./hack/update-generated-docs.sh
+  '';
+
+  installPhase = ''
+    runHook preInstall
+    for p in $WHAT; do
+      install -D _output/local/go/bin/''${p##*/} -t $out/bin
+    done
+
+    cc build/pause/linux/pause.c -o pause
+    install -D pause -t $pause/bin
+
+    rm docs/man/man1/kubectl*
+    installManPage docs/man/man1/*.[1-9]
+
+    ln -s ${kubectl}/bin/kubectl $out/bin/kubectl
+
+    # 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
+    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
+
+    installShellCompletion --cmd kubeadm \
+      --bash <($out/bin/kubeadm completion bash) \
+      --zsh <($out/bin/kubeadm completion zsh)
+    runHook postInstall
+  '';
+
+  disallowedReferences = [ go ];
+
+  GOFLAGS = [ "-trimpath" ];
+
+  meta = with lib; {
+    description = "Production-Grade Container Scheduling and Management";
+    license = licenses.asl20;
+    homepage = "https://kubernetes.io";
+    maintainers = with maintainers; [ ] ++ teams.kubernetes.members;
+    platforms = platforms.linux;
+  };
+
+  passthru.tests = nixosTests.kubernetes;
+}