-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdyn.nix
More file actions
69 lines (62 loc) · 1.86 KB
/
dyn.nix
File metadata and controls
69 lines (62 loc) · 1.86 KB
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
defaultArgs:
{
src,
vendorHash ? null,
subPackage ? "", # relative to module, do not include "./" prefix
pkgs ? defaultArgs.pkgs,
go ? pkgs.go,
# use nix 2.32.5 or higher for best results with dynamic derivations
innerNix ? pkgs.nixVersions.nix_2_32,
env ? { },
}:
let
argenv = env;
processBuild = pkgs.callPackage ./process-build/package.nix { };
getModule = pkgs.callPackage ./getModule.nix { };
in
let
proxyenv = argenv // {
CGO_ENABLED = argenv.CGO_ENABLED or go.CGO_ENABLED;
};
env = proxyenv // {
GOPROXY = "off";
};
splitmodsjoin =
if vendorHash == null then
null
else
let
modpkg = pkgs.runCommand "dgd-deps" {
inherit src go;
env = proxyenv;
outputHash = vendorHash;
outputHashMode = "recursive";
} (builtins.readFile ./script/download.sh);
splitmoddrv = pkgs.runCommandLocal "dgd-joined-deps.drv" {
inherit modpkg innerNix;
pkgsPath = pkgs.path; # TODO: avoid copying to store if already in store?
outputHashMode = "text";
requiredSystemFeatures = [ "recursive-nix" ];
__contentAddressed = true; # why is this needed???
} (builtins.readFile ./script/split.sh);
in
builtins.outputOf splitmoddrv.outPath "out";
modname = getModule (src + "/go.mod") subPackage;
dynDrv = pkgs.runCommand "dgd-${modname}-bin.drv" {
inherit
src
go
innerNix
processBuild
splitmodsjoin
subPackage
;
envJson = builtins.toJSON env;
pkgsPath = pkgs.path; # TODO: avoid copying to store if already in store?
outputHashMode = "text";
requiredSystemFeatures = [ "recursive-nix" ];
__contentAddressed = true; # needed to depend on a dynamic derivation??
} (builtins.readFile ./script/build-n.sh);
out = builtins.outputOf dynDrv.outPath "out";
in
out