Reusing go libs in deis build
This commit is contained in:
parent
5c2628a704
commit
81f3092e11
@ -1,4 +1,4 @@
|
|||||||
{ go, govers, parallel, lib }:
|
{ go, govers, parallel, lib, fetchgit }:
|
||||||
|
|
||||||
{ name, buildInputs ? [], nativeBuildInputs ? [], passthru ? {}, preFixup ? ""
|
{ name, buildInputs ? [], nativeBuildInputs ? [], passthru ? {}, preFixup ? ""
|
||||||
|
|
||||||
@ -17,6 +17,9 @@
|
|||||||
# Extra sources to include in the gopath
|
# Extra sources to include in the gopath
|
||||||
, extraSrcs ? [ ]
|
, extraSrcs ? [ ]
|
||||||
|
|
||||||
|
# go2nix dependency file
|
||||||
|
, goDeps ? null
|
||||||
|
|
||||||
, dontRenameImports ? false
|
, dontRenameImports ? false
|
||||||
|
|
||||||
# Do not enable this without good reason
|
# Do not enable this without good reason
|
||||||
@ -27,6 +30,8 @@
|
|||||||
|
|
||||||
if disabled then throw "${name} not supported for go ${go.meta.branch}" else
|
if disabled then throw "${name} not supported for go ${go.meta.branch}" else
|
||||||
|
|
||||||
|
with builtins;
|
||||||
|
|
||||||
let
|
let
|
||||||
args = lib.filterAttrs (name: _: name != "extraSrcs") args';
|
args = lib.filterAttrs (name: _: name != "extraSrcs") args';
|
||||||
|
|
||||||
@ -35,6 +40,27 @@ let
|
|||||||
removeExpr = refs: lib.flip lib.concatMapStrings refs (ref: ''
|
removeExpr = refs: lib.flip lib.concatMapStrings refs (ref: ''
|
||||||
| sed "s,${ref},$(echo "${ref}" | sed "s,$NIX_STORE/[^-]*,$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee,"),g" \
|
| sed "s,${ref},$(echo "${ref}" | sed "s,$NIX_STORE/[^-]*,$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee,"),g" \
|
||||||
'');
|
'');
|
||||||
|
|
||||||
|
dep2src = goDep:
|
||||||
|
{
|
||||||
|
inherit (goDep) goPackagePath;
|
||||||
|
src = if goDep.fetch.type == "git" then
|
||||||
|
fetchgit {
|
||||||
|
inherit (goDep.fetch) url rev sha256;
|
||||||
|
}
|
||||||
|
else {};
|
||||||
|
};
|
||||||
|
|
||||||
|
importGodeps = { depsFile, filterPackages ? [] }:
|
||||||
|
let
|
||||||
|
deps = lib.importJSON depsFile;
|
||||||
|
external = filter (d: d ? include) deps;
|
||||||
|
direct = filter (d: d ? goPackagePath && (length filterPackages == 0 || elem d.goPackagePath filterPackages)) deps;
|
||||||
|
in
|
||||||
|
concatLists (map importGodeps (map (d: { depsFile = ./. + d.include; filterPackages = d.packages; }) external)) ++ (map dep2src direct);
|
||||||
|
|
||||||
|
goPath = if goDeps != null then importGodeps { depsFile = goDeps; } ++ extraSrcs
|
||||||
|
else extraSrcs;
|
||||||
in
|
in
|
||||||
|
|
||||||
go.stdenv.mkDerivation (
|
go.stdenv.mkDerivation (
|
||||||
@ -53,13 +79,13 @@ go.stdenv.mkDerivation (
|
|||||||
mkdir -p "go/src/$(dirname "$goPackagePath")"
|
mkdir -p "go/src/$(dirname "$goPackagePath")"
|
||||||
mv "$sourceRoot" "go/src/$goPackagePath"
|
mv "$sourceRoot" "go/src/$goPackagePath"
|
||||||
|
|
||||||
'' + lib.flip lib.concatMapStrings extraSrcs ({ src, goPackagePath }: ''
|
'' + lib.flip lib.concatMapStrings goPath ({ src, goPackagePath }: ''
|
||||||
mkdir extraSrc
|
mkdir goPath
|
||||||
(cd extraSrc; unpackFile "${src}")
|
(cd goPath; unpackFile "${src}")
|
||||||
mkdir -p "go/src/$(dirname "${goPackagePath}")"
|
mkdir -p "go/src/$(dirname "${goPackagePath}")"
|
||||||
chmod -R u+w extraSrc/*
|
chmod -R u+w goPath/*
|
||||||
mv extraSrc/* "go/src/${goPackagePath}"
|
mv goPath/* "go/src/${goPackagePath}"
|
||||||
rmdir extraSrc
|
rmdir goPath
|
||||||
|
|
||||||
'') + ''
|
'') + ''
|
||||||
export GOPATH=$NIX_BUILD_TOP/go:$GOPATH
|
export GOPATH=$NIX_BUILD_TOP/go:$GOPATH
|
||||||
|
@ -25,5 +25,23 @@
|
|||||||
"rev": "a83829b6f1293c91addabc89d0571c246397bbf4",
|
"rev": "a83829b6f1293c91addabc89d0571c246397bbf4",
|
||||||
"sha256": "1m4dsmk90sbi17571h6pld44zxz7jc4lrnl4f27dpd1l8g5xvjhh"
|
"sha256": "1m4dsmk90sbi17571h6pld44zxz7jc4lrnl4f27dpd1l8g5xvjhh"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"goPackagePath": "github.com/docopt/docopt-go",
|
||||||
|
"fetch": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/docopt/docopt-go",
|
||||||
|
"rev": "784ddc588536785e7299f7272f39101f7faccc3f",
|
||||||
|
"sha256": "13x00cnady5znysfwca3x59dl04m8rvnk2yprgyqqpg2y4v0xmbf"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"goPackagePath": "golang.org/x/crypto",
|
||||||
|
"fetch": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://go.googlesource.com/crypto",
|
||||||
|
"rev": "1f22c0103821b9390939b6776727195525381532",
|
||||||
|
"sha256": "05ahvn9g9cj7797n8ryfxv2g26v3lx1pza9d9pg97iw0rvar9i1h"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
@ -1,5 +1,5 @@
|
|||||||
# This file was generated by go2nix.
|
# This file was generated by go2nix.
|
||||||
{ stdenv, lib, goPackages, fetchgit, fetchhg, fetchbzr, fetchsvn }:
|
{ stdenv, lib, goPackages, fetchgit }:
|
||||||
|
|
||||||
with goPackages;
|
with goPackages;
|
||||||
|
|
||||||
@ -23,14 +23,5 @@ buildGoPackage rec {
|
|||||||
sha256 = "1fblg3gf7dh5hhm4ajq7yl7iy6gw8p5xlh4z8kvfy542m1fzr0dc";
|
sha256 = "1fblg3gf7dh5hhm4ajq7yl7iy6gw8p5xlh4z8kvfy542m1fzr0dc";
|
||||||
};
|
};
|
||||||
|
|
||||||
extraSrcs = map ( jsonDep:
|
goDeps = ./deps.json;
|
||||||
{
|
|
||||||
inherit (jsonDep) goPackagePath;
|
|
||||||
src = if jsonDep.fetch.type == "git" then
|
|
||||||
fetchgit {
|
|
||||||
inherit (jsonDep.fetch) url rev sha256;
|
|
||||||
}
|
|
||||||
else {};
|
|
||||||
}
|
|
||||||
) (builtins.fromJSON (builtins.readFile ../../go-modules/libs.json));
|
|
||||||
}
|
}
|
||||||
|
10
pkgs/development/tools/deis/deps.json
Normal file
10
pkgs/development/tools/deis/deps.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"include": "../../../go-modules/libs.json",
|
||||||
|
"packages": [
|
||||||
|
"github.com/docopt/docopt-go",
|
||||||
|
"golang.org/x/crypto",
|
||||||
|
"gopkg.in/yaml.v2"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
@ -1,31 +1,9 @@
|
|||||||
# This file was generated by go2nix.
|
# This file was generated by go2nix.
|
||||||
{ stdenv, lib, goPackages, fetchgit, fetchhg, fetchbzr, fetchsvn }:
|
{ stdenv, lib, goPackages, fetchgit }:
|
||||||
|
|
||||||
with builtins;
|
with builtins;
|
||||||
with goPackages;
|
with goPackages;
|
||||||
|
|
||||||
let
|
|
||||||
depToSrc = jsonDep:
|
|
||||||
{
|
|
||||||
inherit (jsonDep) goPackagePath;
|
|
||||||
src = if jsonDep.fetch.type == "git" then
|
|
||||||
fetchgit {
|
|
||||||
inherit (jsonDep.fetch) url rev sha256;
|
|
||||||
}
|
|
||||||
else {};
|
|
||||||
};
|
|
||||||
|
|
||||||
importGodeps = { depsFile, filterPackages ? [] }:
|
|
||||||
let
|
|
||||||
deps = lib.importJSON depsFile;
|
|
||||||
external = filter (d: d ? include) deps;
|
|
||||||
direct = filter (d: d ? goPackagePath && (length filterPackages == 0 || elem d.goPackagePath filterPackages)) deps;
|
|
||||||
in
|
|
||||||
concatLists (map importGodeps (map (d: { depsFile = ./. + d.include; filterPackages = d.packages; }) external)) ++ (map depToSrc direct);
|
|
||||||
|
|
||||||
godeps = importGodeps { depsFile = ./deps.json; };
|
|
||||||
in
|
|
||||||
|
|
||||||
buildGoPackage rec {
|
buildGoPackage rec {
|
||||||
name = "gawp-${version}";
|
name = "gawp-${version}";
|
||||||
version = "20160121-${stdenv.lib.strings.substring 0 7 rev}";
|
version = "20160121-${stdenv.lib.strings.substring 0 7 rev}";
|
||||||
@ -39,5 +17,5 @@ buildGoPackage rec {
|
|||||||
sha256 = "0r4bp4w3s9rkmg3cz9jb7d6ngh7vfj31p9kbim6mhilxvmgjk4ly";
|
sha256 = "0r4bp4w3s9rkmg3cz9jb7d6ngh7vfj31p9kbim6mhilxvmgjk4ly";
|
||||||
};
|
};
|
||||||
|
|
||||||
extraSrcs = godeps;
|
goDeps = ./deps.json;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user