forked from unionlabs/union
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuniond.nix
108 lines (103 loc) · 3.53 KB
/
uniond.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
_: {
perSystem =
{
pkgs,
self',
crane,
system,
ensureAtRepositoryRoot,
nix-filter,
gitRev,
uniondBundleVersions,
goPkgs,
mkCi,
...
}:
let
libwasmvm = self'.packages.libwasmvm-2_1_3;
CGO_LDFLAGS = "-z noexecstack -static -L${goPkgs.musl}/lib -L${libwasmvm}/lib -s -w";
mkUniondImage =
uniond:
pkgs.dockerTools.buildImage {
name = "uniond";
copyToRoot = pkgs.buildEnv {
name = "image-root";
paths = [
pkgs.coreutils
pkgs.cacert
uniond
];
pathsToLink = [ "/bin" ];
};
config = {
Entrypoint = [ "uniond" ];
Cmd = [ "start" ];
Env = [ "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" ];
};
};
in
{
packages = {
# Statically link on Linux using `pkgsStatic`, dynamically link on Darwin using normal `pkgs`.
uniond =
(if pkgs.stdenv.isLinux then goPkgs.pkgsStatic.buildGo123Module else goPkgs.buildGo123Module)
(
{
name = "uniond";
src = nix-filter {
name = "uniond-source";
root = ./.;
exclude = [
(nix-filter.matchExt "nix")
(nix-filter.matchExt "md")
];
};
vendorHash = "sha256-NcTCWXTmjMYkv3cEgcIyhEy18ynELvceEdofBFQVlgM=";
doCheck = true;
meta.mainProgram = "uniond";
}
// (
if pkgs.stdenv.isLinux then
{
inherit CGO_LDFLAGS;
nativeBuildInputs = [ goPkgs.musl ];
ldflags = [
"-linkmode external"
"-X github.com/cosmos/cosmos-sdk/version.Name=uniond"
"-X github.com/cosmos/cosmos-sdk/version.AppName=uniond"
];
}
else if pkgs.stdenv.isDarwin then
{
# Dynamically link if we're on darwin by wrapping the program
# such that the DYLD_LIBRARY_PATH includes libwasmvm
buildInputs = [ pkgs.makeWrapper ];
postFixup = ''
wrapProgram $out/ bin/uniond \
--set DYLD_LIBRARY_PATH ${(pkgs.lib.makeLibraryPath [ libwasmvm ])};
'';
ldflags = [
"-X github.com/cosmos/cosmos-sdk/version.Name=uniond"
"-X github.com/cosmos/cosmos-sdk/version.AppName=uniond"
];
}
else
{ }
)
);
uniond-release = mkCi false (
self'.packages.uniond.overrideAttrs (old: {
ldflags = old.ldflags ++ [
"-X github.com/cosmos/cosmos-sdk/version.Name=uniond"
"-X github.com/cosmos/cosmos-sdk/version.AppName=uniond"
"-X github.com/cosmos/cosmos-sdk/version.BuildTags=${system}"
"-X github.com/cosmos/cosmos-sdk/version.Commit=${gitRev}"
"-X github.com/cosmos/cosmos-sdk/version.Version=${uniondBundleVersions.last}"
];
})
);
uniond-image = mkUniondImage self'.packages.uniond;
uniond-release-image = mkUniondImage self'.packages.uniond-release;
};
};
}