tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
Reusing go libs in deis build
Kamil Chmielewski
9 years ago
81f3092e
5c2628a7
+66
-43
5 changed files
expand all
collapse all
unified
split
pkgs
development
go-modules
generic
default.nix
libs.json
tools
deis
default.nix
deps.json
tools
misc
gawp
default.nix
+33
-7
pkgs/development/go-modules/generic/default.nix
···
1
-
{ go, govers, parallel, lib }:
2
3
{ name, buildInputs ? [], nativeBuildInputs ? [], passthru ? {}, preFixup ? ""
4
···
16
17
# Extra sources to include in the gopath
18
, extraSrcs ? [ ]
0
0
0
19
20
, dontRenameImports ? false
21
···
27
28
if disabled then throw "${name} not supported for go ${go.meta.branch}" else
29
0
0
30
let
31
args = lib.filterAttrs (name: _: name != "extraSrcs") args';
32
···
35
removeExpr = refs: lib.flip lib.concatMapStrings refs (ref: ''
36
| sed "s,${ref},$(echo "${ref}" | sed "s,$NIX_STORE/[^-]*,$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee,"),g" \
37
'');
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
38
in
39
40
go.stdenv.mkDerivation (
···
53
mkdir -p "go/src/$(dirname "$goPackagePath")"
54
mv "$sourceRoot" "go/src/$goPackagePath"
55
56
-
'' + lib.flip lib.concatMapStrings extraSrcs ({ src, goPackagePath }: ''
57
-
mkdir extraSrc
58
-
(cd extraSrc; unpackFile "${src}")
59
mkdir -p "go/src/$(dirname "${goPackagePath}")"
60
-
chmod -R u+w extraSrc/*
61
-
mv extraSrc/* "go/src/${goPackagePath}"
62
-
rmdir extraSrc
63
64
'') + ''
65
export GOPATH=$NIX_BUILD_TOP/go:$GOPATH
···
1
+
{ go, govers, parallel, lib, fetchgit }:
2
3
{ name, buildInputs ? [], nativeBuildInputs ? [], passthru ? {}, preFixup ? ""
4
···
16
17
# Extra sources to include in the gopath
18
, extraSrcs ? [ ]
19
+
20
+
# go2nix dependency file
21
+
, goDeps ? null
22
23
, dontRenameImports ? false
24
···
30
31
if disabled then throw "${name} not supported for go ${go.meta.branch}" else
32
33
+
with builtins;
34
+
35
let
36
args = lib.filterAttrs (name: _: name != "extraSrcs") args';
37
···
40
removeExpr = refs: lib.flip lib.concatMapStrings refs (ref: ''
41
| sed "s,${ref},$(echo "${ref}" | sed "s,$NIX_STORE/[^-]*,$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee,"),g" \
42
'');
43
+
44
+
dep2src = goDep:
45
+
{
46
+
inherit (goDep) goPackagePath;
47
+
src = if goDep.fetch.type == "git" then
48
+
fetchgit {
49
+
inherit (goDep.fetch) url rev sha256;
50
+
}
51
+
else {};
52
+
};
53
+
54
+
importGodeps = { depsFile, filterPackages ? [] }:
55
+
let
56
+
deps = lib.importJSON depsFile;
57
+
external = filter (d: d ? include) deps;
58
+
direct = filter (d: d ? goPackagePath && (length filterPackages == 0 || elem d.goPackagePath filterPackages)) deps;
59
+
in
60
+
concatLists (map importGodeps (map (d: { depsFile = ./. + d.include; filterPackages = d.packages; }) external)) ++ (map dep2src direct);
61
+
62
+
goPath = if goDeps != null then importGodeps { depsFile = goDeps; } ++ extraSrcs
63
+
else extraSrcs;
64
in
65
66
go.stdenv.mkDerivation (
···
79
mkdir -p "go/src/$(dirname "$goPackagePath")"
80
mv "$sourceRoot" "go/src/$goPackagePath"
81
82
+
'' + lib.flip lib.concatMapStrings goPath ({ src, goPackagePath }: ''
83
+
mkdir goPath
84
+
(cd goPath; unpackFile "${src}")
85
mkdir -p "go/src/$(dirname "${goPackagePath}")"
86
+
chmod -R u+w goPath/*
87
+
mv goPath/* "go/src/${goPackagePath}"
88
+
rmdir goPath
89
90
'') + ''
91
export GOPATH=$NIX_BUILD_TOP/go:$GOPATH
+19
-1
pkgs/development/go-modules/libs.json
···
25
"rev": "a83829b6f1293c91addabc89d0571c246397bbf4",
26
"sha256": "1m4dsmk90sbi17571h6pld44zxz7jc4lrnl4f27dpd1l8g5xvjhh"
27
}
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
28
}
29
-
]
···
25
"rev": "a83829b6f1293c91addabc89d0571c246397bbf4",
26
"sha256": "1m4dsmk90sbi17571h6pld44zxz7jc4lrnl4f27dpd1l8g5xvjhh"
27
}
28
+
},
29
+
{
30
+
"goPackagePath": "github.com/docopt/docopt-go",
31
+
"fetch": {
32
+
"type": "git",
33
+
"url": "https://github.com/docopt/docopt-go",
34
+
"rev": "784ddc588536785e7299f7272f39101f7faccc3f",
35
+
"sha256": "13x00cnady5znysfwca3x59dl04m8rvnk2yprgyqqpg2y4v0xmbf"
36
+
}
37
+
},
38
+
{
39
+
"goPackagePath": "golang.org/x/crypto",
40
+
"fetch": {
41
+
"type": "git",
42
+
"url": "https://go.googlesource.com/crypto",
43
+
"rev": "1f22c0103821b9390939b6776727195525381532",
44
+
"sha256": "05ahvn9g9cj7797n8ryfxv2g26v3lx1pza9d9pg97iw0rvar9i1h"
45
+
}
46
}
47
+
]
+2
-11
pkgs/development/tools/deis/default.nix
···
1
# This file was generated by go2nix.
2
-
{ stdenv, lib, goPackages, fetchgit, fetchhg, fetchbzr, fetchsvn }:
3
4
with goPackages;
5
···
23
sha256 = "1fblg3gf7dh5hhm4ajq7yl7iy6gw8p5xlh4z8kvfy542m1fzr0dc";
24
};
25
26
-
extraSrcs = map ( jsonDep:
27
-
{
28
-
inherit (jsonDep) goPackagePath;
29
-
src = if jsonDep.fetch.type == "git" then
30
-
fetchgit {
31
-
inherit (jsonDep.fetch) url rev sha256;
32
-
}
33
-
else {};
34
-
}
35
-
) (builtins.fromJSON (builtins.readFile ../../go-modules/libs.json));
36
}
···
1
# This file was generated by go2nix.
2
+
{ stdenv, lib, goPackages, fetchgit }:
3
4
with goPackages;
5
···
23
sha256 = "1fblg3gf7dh5hhm4ajq7yl7iy6gw8p5xlh4z8kvfy542m1fzr0dc";
24
};
25
26
+
goDeps = ./deps.json;
0
0
0
0
0
0
0
0
0
27
}
+10
pkgs/development/tools/deis/deps.json
···
0
0
0
0
0
0
0
0
0
0
···
1
+
[
2
+
{
3
+
"include": "../../../go-modules/libs.json",
4
+
"packages": [
5
+
"github.com/docopt/docopt-go",
6
+
"golang.org/x/crypto",
7
+
"gopkg.in/yaml.v2"
8
+
]
9
+
}
10
+
]
+2
-24
pkgs/tools/misc/gawp/default.nix
···
1
# This file was generated by go2nix.
2
-
{ stdenv, lib, goPackages, fetchgit, fetchhg, fetchbzr, fetchsvn }:
3
4
with builtins;
5
with goPackages;
6
7
-
let
8
-
depToSrc = jsonDep:
9
-
{
10
-
inherit (jsonDep) goPackagePath;
11
-
src = if jsonDep.fetch.type == "git" then
12
-
fetchgit {
13
-
inherit (jsonDep.fetch) url rev sha256;
14
-
}
15
-
else {};
16
-
};
17
-
18
-
importGodeps = { depsFile, filterPackages ? [] }:
19
-
let
20
-
deps = lib.importJSON depsFile;
21
-
external = filter (d: d ? include) deps;
22
-
direct = filter (d: d ? goPackagePath && (length filterPackages == 0 || elem d.goPackagePath filterPackages)) deps;
23
-
in
24
-
concatLists (map importGodeps (map (d: { depsFile = ./. + d.include; filterPackages = d.packages; }) external)) ++ (map depToSrc direct);
25
-
26
-
godeps = importGodeps { depsFile = ./deps.json; };
27
-
in
28
-
29
buildGoPackage rec {
30
name = "gawp-${version}";
31
version = "20160121-${stdenv.lib.strings.substring 0 7 rev}";
···
39
sha256 = "0r4bp4w3s9rkmg3cz9jb7d6ngh7vfj31p9kbim6mhilxvmgjk4ly";
40
};
41
42
-
extraSrcs = godeps;
43
}
···
1
# This file was generated by go2nix.
2
+
{ stdenv, lib, goPackages, fetchgit }:
3
4
with builtins;
5
with goPackages;
6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7
buildGoPackage rec {
8
name = "gawp-${version}";
9
version = "20160121-${stdenv.lib.strings.substring 0 7 rev}";
···
17
sha256 = "0r4bp4w3s9rkmg3cz9jb7d6ngh7vfj31p9kbim6mhilxvmgjk4ly";
18
};
19
20
+
goDeps = ./deps.json;
21
}