Skip to content

Commit

Permalink
Install crossplane cli via nix
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuheechul committed Mar 29, 2021
1 parent 35b71c3 commit 70fdb43
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
2 changes: 2 additions & 0 deletions crossplane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ You will needs these:
- minikube
- terraform

You may look at [this](https://crossplane.io/docs/v1.1/getting-started/install-configure.html) for additional requirements.

## Play

Use [Makefile](./Makefile) to provision and run and teardown.
Expand Down
28 changes: 28 additions & 0 deletions crossplane/crossplane-cli.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# this derivation is based on https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh
{ pkgs , artifactVersion ? "v1.1.0" }:

# TODO: support multi OS and arch - currently only darwin_amd64 is hard coded

with pkgs; let
# fix this to adapt different arch - https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh
os_arch = "darwin_amd64";
artifactSha256 = "051vyfmdkf2nmxd3ry175cl3bb0hgklgq00vi2ym52sqyfaplwyl";
in
# https://ops.functionalalgebra.com/nix-by-example/
stdenv.mkDerivation rec {
name = "crossplane-cli";
version = "${artifactVersion}";

src = fetchurl {
url = "https://releases.crossplane.io/stable/${artifactVersion}/bin/${os_arch}/crank";
sha256 = "${artifactSha256}";
};

phases = "installPhase";

installPhase = ''
mkdir -p $out/bin
cp ${src} $out/bin/kubectl-crossplane
chmod +x $out/bin/kubectl-crossplane
'';
}
21 changes: 13 additions & 8 deletions crossplane/shell.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{ pkgs ? import <nixpkgs> {} }:

pkgs.mkShell {
buildInputs = with pkgs;[
minikube
kubectl
k9s
kubernetes-helm
terraform_0_14
];
let
crossplane-cli = import ./crossplane-cli.nix { pkgs=pkgs; };
in
pkgs.mkShell {
buildInputs = with pkgs;[
minikube
kubectl
k9s
kubernetes-helm
terraform_0_14
crossplane-cli
];

# Environment variables to set here - https://discourse.nixos.org/t/provide-environmental-variables-from-nix/3453/3
KUBECONFIG = "./.kube/config";
DEBUG_NIX = builtins.currentSystem;
}

0 comments on commit 70fdb43

Please sign in to comment.