From ac7a6e04c20bcf576e02eaa5d230dc2f04d5b9f7 Mon Sep 17 00:00:00 2001 From: Dan Peebles Date: Wed, 29 Jul 2015 04:55:57 +0000 Subject: [PATCH] go-packages: start factoring out repetitive patterns --- pkgs/top-level/go-packages.nix | 42 +++++++++++++++------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/pkgs/top-level/go-packages.nix b/pkgs/top-level/go-packages.nix index cf9971c7407f..956e0c2fedb7 100644 --- a/pkgs/top-level/go-packages.nix +++ b/pkgs/top-level/go-packages.nix @@ -6,38 +6,34 @@ let isGo13 = go.meta.branch == "1.3"; isGo14 = go.meta.branch == "1.4"; + + buildFromGitHub = { rev, owner, repo, sha256, name ? repo, goPackagePath ? "github.com/${owner}/${repo}", ... }@args: buildGoPackage (args // { + inherit goPackagePath; + name = "${name}-${stdenv.lib.strings.substring 0 7 rev}"; + src = fetchFromGitHub { inherit rev owner repo sha256; }; + }); + self = _self // overrides; _self = with self; { inherit go buildGoPackage; ## OFFICIAL GO PACKAGES - crypto = buildGoPackage rec { - rev = "4d48e5fa3d62b5e6e71260571bf76c767198ca02"; - name = "crypto-${stdenv.lib.strings.substring 0 7 rev}"; - goPackagePath = "golang.org/x/crypto"; - goPackageAliases = [ "code.google.com/p/go.crypto" ]; + crypto = buildFromGitHub { + rev = "4d48e5fa3d62b5e6e71260571bf76c767198ca02"; disabled = isGo13; - - src = fetchFromGitHub { - inherit rev; - owner = "golang"; - repo = "crypto"; - sha256 = "0plvjv56afb02p7l3c2zfwffnhscmc3f0ckj1gls9ay6vj85y7l8"; - }; + owner = "golang"; + repo = "crypto"; + sha256 = "0plvjv56afb02p7l3c2zfwffnhscmc3f0ckj1gls9ay6vj85y7l8"; + goPackagePath = "golang.org/x/crypto"; + goPackageAliases = [ "code.google.com/p/go.crypto" ]; }; - glog = buildGoPackage rec { - rev = "44145f04b68cf362d9c4df2182967c2275eaefed"; - name = "glog-${stdenv.lib.strings.substring 0 7 rev}"; - goPackagePath = "github.com/golang/glog"; - - src = fetchFromGitHub { - inherit rev; - owner = "golang"; - repo = "glog"; - sha256 = "1k7sf6qmpgm0iw81gx2dwggf9di6lgw0n54mni7862hihwfrb5rq"; - }; + glog = buildFromGitHub { + rev = "44145f04b68cf362d9c4df2182967c2275eaefed"; + owner = "golang"; + repo = "glog"; + sha256 = "1k7sf6qmpgm0iw81gx2dwggf9di6lgw0n54mni7862hihwfrb5rq"; }; image = buildGoPackage rec {