diff options
author | Christian Kampka <christian@kampka.net> | 2019-07-03 13:00:27 +0200 |
---|---|---|
committer | Christian Kampka <christian@kampka.net> | 2019-08-05 16:06:30 +0200 |
commit | 4d50ce93aa0b20534e8a2e8456e89cfeb58bd422 (patch) | |
tree | 10ca293ac22699bcf7f13bf84cf6704316a8acdd /pkgs/applications/networking/cluster/kops | |
parent | 5aeab0b2ddb554a22f49a7a446ed53b7ce87ab29 (diff) | |
download | nixlib-4d50ce93aa0b20534e8a2e8456e89cfeb58bd422.tar nixlib-4d50ce93aa0b20534e8a2e8456e89cfeb58bd422.tar.gz nixlib-4d50ce93aa0b20534e8a2e8456e89cfeb58bd422.tar.bz2 nixlib-4d50ce93aa0b20534e8a2e8456e89cfeb58bd422.tar.lz nixlib-4d50ce93aa0b20534e8a2e8456e89cfeb58bd422.tar.xz nixlib-4d50ce93aa0b20534e8a2e8456e89cfeb58bd422.tar.zst nixlib-4d50ce93aa0b20534e8a2e8456e89cfeb58bd422.zip |
kops: restructure package to maintain multiple versions in the future
kops versions are bound to the version of the kubernetes cluster they are targeted to maintain (kops 1.12 -> k8s 1.12, kops 1.13 -> k8s 1.13, etc). Upgrading kops should therefore be done very deliberately as it may affect the cluster it is working with in drastic ways. This change introduces the ability to maintain multiple versions of kops in nixpkgs, giving the users the ability to pin it to their target cluster version when installing
Diffstat (limited to 'pkgs/applications/networking/cluster/kops')
-rw-r--r-- | pkgs/applications/networking/cluster/kops/default.nix | 91 |
1 files changed, 52 insertions, 39 deletions
diff --git a/pkgs/applications/networking/cluster/kops/default.nix b/pkgs/applications/networking/cluster/kops/default.nix index 96f3354023cf..cd6cd9ee22b2 100644 --- a/pkgs/applications/networking/cluster/kops/default.nix +++ b/pkgs/applications/networking/cluster/kops/default.nix @@ -1,44 +1,57 @@ -{ stdenv, buildGoPackage, fetchFromGitHub, go-bindata }: - -buildGoPackage rec { - name = "kops-${version}"; - version = "1.12.1"; +{ stdenv, lib, buildGoPackage, fetchFromGitHub, go-bindata }: +let goPackagePath = "k8s.io/kops"; - src = fetchFromGitHub { - rev = version; - owner = "kubernetes"; - repo = "kops"; - sha256 = "09rmgazdrmnh1lqaayzfbn0ld7mbj9whihs9ijv5gf6si9p0ml9y"; - }; - - buildInputs = [go-bindata]; - subPackages = ["cmd/kops"]; - - buildFlagsArray = '' - -ldflags= - -X k8s.io/kops.Version=${version} - -X k8s.io/kops.GitVersion=${version} - ''; - - preBuild = '' - (cd go/src/k8s.io/kops - go-bindata -o upup/models/bindata.go -pkg models -prefix upup/models/ upup/models/...) - ''; - - postInstall = '' - mkdir -p $bin/share/bash-completion/completions - mkdir -p $bin/share/zsh/site-functions - $bin/bin/kops completion bash > $bin/share/bash-completion/completions/kops - $bin/bin/kops completion zsh > $bin/share/zsh/site-functions/_kops - ''; - - meta = with stdenv.lib; { - description = "Easiest way to get a production Kubernetes up and running"; - homepage = https://github.com/kubernetes/kops; - license = licenses.asl20; - maintainers = with maintainers; [offline zimbatm]; - platforms = platforms.unix; + generic = { version, sha256, ...}@attrs: + let attrs' = builtins.removeAttrs attrs ["version" "sha256"] ; in + buildGoPackage { + name = "kops-${version}"; + + inherit goPackagePath; + + src = fetchFromGitHub { + rev = version; + owner = "kubernetes"; + repo = "kops"; + inherit sha256; + }; + + buildInputs = [go-bindata]; + subPackages = ["cmd/kops"]; + + buildFlagsArray = '' + -ldflags= + -X k8s.io/kops.Version=${version} + -X k8s.io/kops.GitVersion=${version} + ''; + + preBuild = '' + (cd go/src/k8s.io/kops + go-bindata -o upup/models/bindata.go -pkg models -prefix upup/models/ upup/models/...) + ''; + + postInstall = '' + mkdir -p $bin/share/bash-completion/completions + mkdir -p $bin/share/zsh/site-functions + $bin/bin/kops completion bash > $bin/share/bash-completion/completions/kops + $bin/bin/kops completion zsh > $bin/share/zsh/site-functions/_kops + ''; + + meta = with stdenv.lib; { + description = "Easiest way to get a production Kubernetes up and running"; + homepage = https://github.com/kubernetes/kops; + license = licenses.asl20; + maintainers = with maintainers; [offline zimbatm]; + platforms = platforms.unix; + }; + } // attrs'; +in rec { + + mkKops = generic; + + kops_1_12 = mkKops { + version = "1.12.2"; + sha256 = "0937crwifnld7r5pf5gvab9ibmf8k44dafr9y3hld2p01ijrari1"; }; } |