Created
May 10, 2020 16:29
-
-
Save mitchellh/c47e3333bb78f57836ba2aa8064ad993 to your computer and use it in GitHub Desktop.
Revisions
-
mitchellh created this gist
May 10, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ self: super: { consul-bin = self.callPackage ./hashicorp-generic.nix { name = "consul"; version = "1.7.3"; sha256 = "0k03n7h5h8miqhh3n3y47894vhwdcp8m611w55f826swmq9angl1"; }; # and so on... } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ /* This function creates a derivation for installing binaries directly * from releases.hashicorp.com. */ { name , version , sha256 , system ? builtins.currentSystem , pname ? "${name}-bin" , lib , stdenv , fetchurl , unzip , ... }: 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 ''; }