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 {
description = "Confd package to use.";
default = pkgs.goPackages.confd;
default = pkgs.confd;
type = types.package;
};
};

View File

@ -200,13 +200,13 @@ in {
staticRootPath = mkOption {
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;
};
package = mkOption {
description = "Package to use.";
default = pkgs.goPackages.grafana;
default = pkgs.grafana-backend;
type = types.package;
};
@ -319,7 +319,7 @@ in {
wantedBy = ["multi-user.target"];
after = ["networking.target"];
serviceConfig = {
ExecStart = "${cfg.package}/bin/grafana --config ${cfgFile} web";
ExecStart = "${cfg.package-backend}/bin/grafana --config ${cfgFile} web";
WorkingDirectory = cfg.dataDir;
User = "grafana";
};

View File

@ -95,7 +95,7 @@ in {
wantedBy = [ "multi-user.target" ];
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
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
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
mkdir $bin
dir="$NIX_BUILD_TOP/go/bin"
[ -e "$dir" ] && cp -r $dir $out
[ -e "$dir" ] && cp -r $dir $bin
runHook postInstall
'';
@ -151,7 +149,7 @@ go.stdenv.mkDerivation (
cat $file ${removeExpr removeReferences} > $file.tmp
mv $file.tmp $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
@ -161,6 +159,9 @@ go.stdenv.mkDerivation (
enableParallelBuilding = enableParallelBuilding;
# I prefer to call this dev but propagatedBuildInputs expects $out to exist
outputs = [ "out" "bin" ];
meta = {
# Add default meta information
platforms = lib.platforms.all;

View File

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

View File

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