This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs ? import <nixpkgs> {} }: | |
with pkgs; let | |
# A function that helps us make derivations to grab binary HashiCorp packages | |
mkHashicorpPackage = { name | |
, version | |
, sha256 | |
, system ? builtins.currentSystem | |
, pname ? "${name}-bin" | |
}: let | |
# Mapping of Nix systems to the GOOS/GOARCH pairs. | |
systemMap = { | |
x86_64-linux = "linux_amd64"; | |
i686-linux = "linux_386"; | |
x86_64-darwin = "darwin_amd64"; | |
i686-darwin = "darwin_386"; | |
aarch64-linux = "linux_arm64"; | |
}; | |
# Get our system | |
goSystem = systemMap.${system} or (throw "unsupported system: ${system}"); | |
# url for downloading composed of all the other stuff we built up. | |
url = "https://releases.hashicorp.com/${name}/${version}/${name}_${version}_${goSystem}.zip"; | |
in stdenv.mkDerivation { | |
inherit pname version; | |
src = fetchurl { inherit url sha256; }; | |
# Our source is right where the unzip happens, not in a "src/" directory (default) | |
sourceRoot = "."; | |
# Stripping breaks darwin Go binaries | |
dontStrip = lib.strings.hasPrefix "darwin" goSystem; | |
nativeBuildInputs = [ unzip ]; | |
installPhase = '' | |
mkdir -p $out/bin | |
mv ${name} $out/bin | |
''; | |
}; | |
gomplate = pkgs.stdenv.mkDerivation rec { | |
pname = "gomplate"; | |
version = "3.5.0"; | |
src = fetchurl { | |
url = "https://github.com/hairyhenderson/gomplate/releases/download/v${version}/gomplate_darwin-amd64"; | |
sha256 = "0sszj8bvmlgllgzwc323wkqi5cn4cqaclf08c1gfj5k8mc04y591"; | |
}; | |
# The binaries are not archived | |
dontUnpack = true; | |
# Our source is right where the unzip happens, not in a "src/" directory (default) | |
sourceRoot = "."; | |
# Stripping breaks darwin Go binaries | |
dontStrip = true; | |
installPhase = '' | |
mkdir -p $out/bin | |
cp ${src} $out/bin/gomplate | |
chmod +x $out/bin/gomplate | |
''; | |
}; | |
terraform = mkHashicorpPackage { | |
name = "terraform"; | |
version = "0.12.24"; | |
sha256 = "0krvs64j00ys23hyv9smz2dx1ksa60405mwmivl36p72ll020j3j"; | |
}; | |
nomad = mkHashicorpPackage { | |
name = "nomad"; | |
version = "0.11.1"; | |
sha256 = "0z51k1c1f02jp1x8836vxf7dqdn7prbm196wnz27c87d8jx61pxr"; | |
}; | |
vault = mkHashicorpPackage { | |
name = "vault"; | |
version = "1.4.1"; | |
sha256 = "031n3sq2rwid22q4ra11is6zhypnsjhqa3qqj2qapz2rcb4hrjaf"; | |
}; | |
dependencies = [ | |
coreutils | |
jq | |
gomplate | |
nomad | |
terraform | |
vault | |
pkgs.mysql | |
pkgs.postgresql | |
]; | |
in stdenv.mkDerivation { | |
name = "cloud-sre"; | |
shellHook = lib.strings.concatStringsSep "\n" (map | |
(n: "export PATH=${n}/bin:$PATH") | |
dependencies); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment