goPackages: Split into multiple derivations

This should reduce the closure size for end users who only need go
binaries as well as reduce the size of closures hydra builders consume.
This commit is contained in:
William A. Kennington III 2015-08-29 12:55:52 -07:00
parent 0b4bcaad95
commit 83cf8b0cf8
6 changed files with 44 additions and 39 deletions

View File

@ -63,7 +63,7 @@ in {
package = mkOption { package = mkOption {
description = "Confd package to use."; description = "Confd package to use.";
default = pkgs.goPackages.confd; default = pkgs.confd;
type = types.package; type = types.package;
}; };
}; };

View File

@ -200,13 +200,13 @@ in {
staticRootPath = mkOption { staticRootPath = mkOption {
description = "Root path for static assets."; description = "Root path for static assets.";
default = "${cfg.package}/share/go/src/github.com/grafana/grafana/public"; default = "${cfg.package.out}/share/go/src/github.com/grafana/grafana/public";
type = types.str; type = types.str;
}; };
package = mkOption { package = mkOption {
description = "Package to use."; description = "Package to use.";
default = pkgs.goPackages.grafana; default = pkgs.grafana-backend;
type = types.package; type = types.package;
}; };
@ -319,7 +319,7 @@ in {
wantedBy = ["multi-user.target"]; wantedBy = ["multi-user.target"];
after = ["networking.target"]; after = ["networking.target"];
serviceConfig = { serviceConfig = {
ExecStart = "${cfg.package}/bin/grafana --config ${cfgFile} web"; ExecStart = "${cfg.package-backend}/bin/grafana --config ${cfgFile} web";
WorkingDirectory = cfg.dataDir; WorkingDirectory = cfg.dataDir;
User = "grafana"; User = "grafana";
}; };

View File

@ -95,7 +95,7 @@ in {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
serviceConfig = { serviceConfig = {
ExecStart = "${pkgs.goPackages.hologram}/bin/hologram-server --debug --conf ${cfgFile}"; ExecStart = "${pkgs.hologram}/bin/hologram-server --debug --conf ${cfgFile}";
}; };
}; };
}; };

View File

@ -129,19 +129,17 @@ go.stdenv.mkDerivation (
runHook preInstall runHook preInstall
mkdir -p $out mkdir -p $out
pushd "$NIX_BUILD_TOP/go"
while read f; do
echo "$f" | grep -q '^./\(src\|pkg/[^/]*\)/${goPackagePath}' || continue
mkdir -p "$(dirname "$out/share/go/$f")"
cp "$NIX_BUILD_TOP/go/$f" "$out/share/go/$f"
done < <(find . -type f)
popd
if [ -z "$dontInstallSrc" ]; then mkdir $bin
pushd "$NIX_BUILD_TOP/go"
while read f; do
echo "$f" | grep -q '^./\(src\|pkg/[^/]*\)/${goPackagePath}' || continue
mkdir -p "$(dirname "$out/share/go/$f")"
cp "$NIX_BUILD_TOP/go/$f" "$out/share/go/$f"
done < <(find . -type f)
popd
fi
dir="$NIX_BUILD_TOP/go/bin" dir="$NIX_BUILD_TOP/go/bin"
[ -e "$dir" ] && cp -r $dir $out [ -e "$dir" ] && cp -r $dir $bin
runHook postInstall runHook postInstall
''; '';
@ -151,7 +149,7 @@ go.stdenv.mkDerivation (
cat $file ${removeExpr removeReferences} > $file.tmp cat $file ${removeExpr removeReferences} > $file.tmp
mv $file.tmp $file mv $file.tmp $file
chmod +x $file chmod +x $file
done < <(find $out/bin -type f 2>/dev/null) done < <(find $bin/bin -type f 2>/dev/null)
''; '';
disallowedReferences = lib.optional (!allowGoReference) go disallowedReferences = lib.optional (!allowGoReference) go
@ -161,6 +159,9 @@ go.stdenv.mkDerivation (
enableParallelBuilding = enableParallelBuilding; enableParallelBuilding = enableParallelBuilding;
# I prefer to call this dev but propagatedBuildInputs expects $out to exist
outputs = [ "out" "bin" ];
meta = { meta = {
# Add default meta information # Add default meta information
platforms = lib.platforms.all; platforms = lib.platforms.all;

View File

@ -818,13 +818,13 @@ let
clib = callPackage ../tools/package-management/clib { }; clib = callPackage ../tools/package-management/clib { };
consul = goPackages.consul; consul = goPackages.consul.bin // { outputs = [ "bin" ]; };
consul-ui = callPackage ../servers/consul/ui.nix { }; consul-ui = callPackage ../servers/consul/ui.nix { };
consul-alerts = goPackages.consul-alerts; consul-alerts = goPackages.consul-alerts.bin // { outputs = [ "bin" ]; };
consul-template = goPackages.consul-template; consul-template = goPackages.consul-template.bin // { outputs = [ "bin" ]; };
corosync = callPackage ../servers/corosync { }; corosync = callPackage ../servers/corosync { };
@ -948,7 +948,7 @@ let
mcrypt = callPackage ../tools/misc/mcrypt { }; mcrypt = callPackage ../tools/misc/mcrypt { };
mongodb-tools = goPackages.mongo-tools; mongodb-tools = goPackages.mongo-tools.bin // { outputs = [ "bin" ]; };
mstflint = callPackage ../tools/misc/mstflint { }; mstflint = callPackage ../tools/misc/mstflint { };
@ -1701,7 +1701,8 @@ let
gptfdisk = callPackage ../tools/system/gptfdisk { }; gptfdisk = callPackage ../tools/system/gptfdisk { };
grafana = callPackage ../development/tools/misc/grafana { }; grafana-frontend = callPackage ../development/tools/misc/grafana { };
grafana-backend = pkgs.goPackages.grafana.bin // { outputs = [ "bin" ]; };
grafx2 = callPackage ../applications/graphics/grafx2 {}; grafx2 = callPackage ../applications/graphics/grafx2 {};
@ -2153,7 +2154,7 @@ let
lshw = callPackage ../tools/system/lshw { }; lshw = callPackage ../tools/system/lshw { };
lxc = callPackage ../os-specific/linux/lxc { }; lxc = callPackage ../os-specific/linux/lxc { };
lxd = goPackages.lxd; lxd = goPackages.lxd.bin // { outputs = [ "bin" ]; };
lzip = callPackage ../tools/compression/lzip { }; lzip = callPackage ../tools/compression/lzip { };
@ -4074,7 +4075,7 @@ let
go-repo-root = callPackage ../development/tools/misc/go-repo-root { }; go-repo-root = callPackage ../development/tools/misc/go-repo-root { };
gox = goPackages.gox; gox = goPackages.gox.bin // { outputs = [ "bin" ]; };
gprolog = callPackage ../development/compilers/gprolog { }; gprolog = callPackage ../development/compilers/gprolog { };
@ -8664,7 +8665,7 @@ let
go = go_1_4; go = go_1_4;
buildGoPackage = import ../development/go-modules/generic { buildGoPackage = import ../development/go-modules/generic {
go = go_1_4; go = go_1_4;
govers = go14Packages.govers; govers = go14Packages.govers.bin;
inherit parallel lib; inherit parallel lib;
}; };
overrides = (config.goPackageOverrides or (p: {})) pkgs; overrides = (config.goPackageOverrides or (p: {})) pkgs;
@ -8674,7 +8675,7 @@ let
go = go_1_5; go = go_1_5;
buildGoPackage = import ../development/go-modules/generic { buildGoPackage = import ../development/go-modules/generic {
go = go_1_5; go = go_1_5;
govers = go15Packages.govers; govers = go15Packages.govers.bin;
inherit parallel lib; inherit parallel lib;
}; };
overrides = (config.goPackageOverrides or (p: {})) pkgs; overrides = (config.goPackageOverrides or (p: {})) pkgs;
@ -8958,7 +8959,7 @@ let
dovecot_pigeonhole = callPackage ../servers/mail/dovecot-pigeonhole { }; dovecot_pigeonhole = callPackage ../servers/mail/dovecot-pigeonhole { };
etcd = goPackages.etcd; etcd = goPackages.etcd.bin // { outputs = [ "bin" ]; };
ejabberd = callPackage ../servers/xmpp/ejabberd { ejabberd = callPackage ../servers/xmpp/ejabberd {
erlang = erlangR16; erlang = erlangR16;
@ -8975,7 +8976,7 @@ let
v8 = v8_3_24_10; v8 = v8_3_24_10;
}; };
etcdctl = goPackages.etcd; etcdctl = etcd;
exim = callPackage ../servers/mail/exim { }; exim = callPackage ../servers/mail/exim { };
@ -10084,7 +10085,7 @@ let
gotags = callPackage ../development/tools/gotags { }; gotags = callPackage ../development/tools/gotags { };
golint = goPackages.lint; golint = goPackages.lint.bin // { outputs = [ "bin" ]; };
godep = callPackage ../development/tools/godep { }; godep = callPackage ../development/tools/godep { };
@ -13668,6 +13669,8 @@ let
chessdb = callPackage ../games/chessdb { }; chessdb = callPackage ../games/chessdb { };
confd = pkgs.goPackages.conf.bin // { outputs = [ "bin" ]; };
construoBase = lowPrio (callPackage ../games/construo { construoBase = lowPrio (callPackage ../games/construo {
mesa = null; mesa = null;
freeglut = null; freeglut = null;
@ -14529,6 +14532,8 @@ let
camlp5 = ocamlPackages.camlp5_strict; camlp5 = ocamlPackages.camlp5_strict;
}; };
hologram = pkgs.goPackages.bin // { outputs = [ "bin" ]; };
isabelle = import ../applications/science/logic/isabelle { isabelle = import ../applications/science/logic/isabelle {
inherit (pkgs) stdenv fetchurl nettools perl polyml; inherit (pkgs) stdenv fetchurl nettools perl polyml;
inherit (pkgs.emacs24Packages) proofgeneral; inherit (pkgs.emacs24Packages) proofgeneral;
@ -15130,7 +15135,7 @@ let
utf8proc = callPackage ../development/libraries/utf8proc { }; utf8proc = callPackage ../development/libraries/utf8proc { };
vault = goPackages.vault; vault = goPackages.vault.bin // { outputs = [ "bin" ]; };
vbam = callPackage ../misc/emulators/vbam { vbam = callPackage ../misc/emulators/vbam {
inherit (xlibs) libpthreadstubs; inherit (xlibs) libpthreadstubs;

View File

@ -130,12 +130,12 @@ let
preConfigure = '' preConfigure = ''
# Make the builtin tools available here # Make the builtin tools available here
mkdir -p $out/bin mkdir -p $bin/bin
eval $(go env | grep GOTOOLDIR) eval $(go env | grep GOTOOLDIR)
find $GOTOOLDIR -type f | while read x; do find $GOTOOLDIR -type f | while read x; do
ln -sv "$x" "$out/bin" ln -sv "$x" "$binbin"
done done
export GOTOOLDIR=$out/bin export GOTOOLDIR=$bin/bin
''; '';
excludedPackages = "\\(" excludedPackages = "\\("
@ -381,11 +381,11 @@ let
}; };
consul = buildFromGitHub { consul = buildFromGitHub {
rev = "a6317f2fb2ba9d5ae695f7fa703cfb30a1c59af1"; rev = "4adc0b5c660919e3f21c9a60f567fd872b9e3d1e";
date = "2015-07-24"; date = "2015-08-27";
owner = "hashicorp"; owner = "hashicorp";
repo = "consul"; repo = "consul";
sha256 = "0jixpl9yksasqx9rkidx8qmqc59m34kiibsqfsv56g87wzyp89rs"; sha256 = "1h4hbyr2c8yfmn5ijga5zx470mdplg231kbxbqfpvswrk69q89j3";
buildInputs = [ buildInputs = [
circbuf armon.go-metrics go-radix gomdb bolt consul-migrate go-checkpoint circbuf armon.go-metrics go-radix gomdb bolt consul-migrate go-checkpoint
@ -1326,7 +1326,6 @@ let
repo = "lint"; repo = "lint";
sha256 = "1bj7zv534hyh87bp2vsbhp94qijc5nixb06li1dzfz9n0wcmlqw9"; sha256 = "1bj7zv534hyh87bp2vsbhp94qijc5nixb06li1dzfz9n0wcmlqw9";
excludedPackages = "testdata"; excludedPackages = "testdata";
dontInstallSrc = true;
buildInputs = [ tools ]; buildInputs = [ tools ];
}; };
@ -1719,11 +1718,11 @@ let
# Mongodb incorrectly names all of their binaries main # Mongodb incorrectly names all of their binaries main
# Let's work around this with our own installer # Let's work around this with our own installer
installPhase = '' installPhase = ''
mkdir -p $out/bin mkdir -p $bin/bin
while read b; do while read b; do
rm -f go/bin/main rm -f go/bin/main
go install $goPackagePath/$b/main go install $goPackagePath/$b/main
cp go/bin/main $out/bin/$b cp go/bin/main $bin/bin/$b
done < <(find go/src/$goPackagePath -name main | xargs dirname | xargs basename -a) done < <(find go/src/$goPackagePath -name main | xargs dirname | xargs basename -a)
''; '';
}; };