3
3
lib ,
4
4
dream2nix ,
5
5
...
6
- } @ topArgs : let
6
+ } : let
7
7
l = lib // builtins ;
8
8
9
- dreamLock = config . rust-cargo-lock . dreamLock ;
10
-
11
- sourceRoot = config . mkDerivation . src ;
12
-
13
- fetchDreamLockSources =
14
- import ../../../lib/internal/fetchDreamLockSources.nix
15
- { inherit lib ; } ;
16
- getDreamLockSource = import ../../../lib/internal/getDreamLockSource.nix { inherit lib ; } ;
17
9
readDreamLock = import ../../../lib/internal/readDreamLock.nix { inherit lib ; } ;
18
- hashPath = import ../../../lib/internal/hashPath.nix {
19
- inherit lib ;
20
- inherit ( config . deps ) runCommandLocal nix ;
21
- } ;
22
- hashFile = import ../../../lib/internal/hashFile.nix {
23
- inherit lib ;
24
- inherit ( config . deps ) runCommandLocal nix ;
25
- } ;
26
-
27
- # fetchers
28
- fetchers = {
29
- git = import ../../../lib/internal/fetchers/git {
30
- inherit hashPath ;
31
- inherit ( config . deps ) fetchgit ;
32
- } ;
33
- http = import ../../../lib/internal/fetchers/http {
34
- inherit hashFile lib ;
35
- inherit ( config . deps . stdenv ) mkDerivation ;
36
- inherit ( config . deps ) fetchurl ;
37
- } ;
38
- crates-io = import ../../../lib/internal/fetchers/crates-io {
39
- inherit hashFile ;
40
- inherit ( config . deps ) fetchurl runCommandLocal ;
41
- } ;
42
- } ;
43
10
44
11
dreamLockLoaded =
45
12
readDreamLock { inherit ( config . rust-cargo-lock ) dreamLock ; } ;
46
13
dreamLockInterface = dreamLockLoaded . interface ;
47
14
48
- fetchedSources' = fetchDreamLockSources {
49
- inherit ( dreamLockInterface ) defaultPackageName defaultPackageVersion ;
50
- inherit ( dreamLockLoaded . lock ) sources ;
51
- inherit fetchers ;
52
- } ;
53
-
54
- fetchedSources =
55
- fetchedSources'
56
- // {
57
- ${ defaultPackageName } . ${ defaultPackageVersion } = sourceRoot ;
58
- } ;
59
-
60
- # name: version: -> store-path
61
- getSource = getDreamLockSource fetchedSources ;
62
-
63
15
inherit
64
16
( dreamLockInterface )
65
- getDependencies # name: version: -> [ {name=; version=; } ]
66
- # Attributes
67
-
68
17
subsystemAttrs # attrset
69
- packageVersions
70
- defaultPackageName
71
- defaultPackageVersion
72
18
;
73
19
74
- toTOML = import ../../../lib/internal/toTOML.nix { inherit lib ; } ;
75
-
76
- utils = import ./utils.nix {
77
- inherit dreamLock getSource lib toTOML sourceRoot ;
78
- inherit
79
- ( dreamLockInterface )
80
- getSourceSpec
81
- getRoot
82
- subsystemAttrs
83
- packages
84
- ;
85
- inherit
86
- ( config . deps )
87
- writeText
88
- ;
89
- } ;
90
-
91
- vendoring = import ./vendor.nix {
92
- inherit dreamLock getSource lib ;
93
- inherit
94
- ( dreamLockInterface )
95
- getSourceSpec
96
- subsystemAttrs
97
- ;
98
- inherit
99
- ( config . deps )
100
- cargo
101
- jq
102
- moreutils
103
- python3Packages
104
- runCommandLocal
105
- writePython3
106
- ;
107
- } ;
20
+ meta = let
21
+ meta = subsystemAttrs . meta . ${ pname } . ${ version } ;
22
+ in
23
+ meta
24
+ // {
25
+ license = l . map ( name : l . licenses . ${ name } ) meta . license ;
26
+ } ;
108
27
109
28
pname = config . name ;
110
29
version = config . version ;
111
30
112
- src = utils . getRootSource pname version ;
31
+ src = config . rust-cargo-vendor . getRootSource pname version ;
113
32
replacePaths =
114
- utils . replaceRelativePathsWithAbsolute
33
+ config . rust-cargo-vendor . replaceRelativePathsWithAbsolute
115
34
subsystemAttrs . relPathReplacements . ${ pname } . ${ version } ;
116
- writeGitVendorEntries = vendoring . writeGitVendorEntries "vendored-sources" ;
35
+ writeGitVendorEntries = config . rust-cargo-vendor . writeGitVendorEntries "vendored-sources" ;
117
36
118
37
cargoBuildFlags = "--package ${ pname } " ;
119
38
buildArgs = {
120
39
inherit pname version ;
121
40
src = lib . mkForce src ;
122
41
123
- meta = utils . getMeta pname version ;
42
+ inherit meta ;
124
43
125
44
cargoBuildFlags = cargoBuildFlags ;
126
45
cargoTestFlags = cargoBuildFlags ;
127
46
128
47
cargoVendorDir = "../nix-vendor" ;
129
- dream2nixVendorDir = vendoring . vendoredDependencies ;
48
+ dream2nixVendorDir = config . rust-cargo-vendor . vendoredSources ;
130
49
131
50
postUnpack = ''
132
- ${ vendoring . copyVendorDir "$dream2nixVendorDir" "./nix-vendor" }
51
+ ${ config . rust-cargo-vendor . copyVendorDir "$dream2nixVendorDir" "./nix-vendor" }
133
52
export CARGO_HOME=$(pwd)/.cargo_home
134
53
'' ;
135
54
140
59
fi
141
60
${ writeGitVendorEntries }
142
61
${ replacePaths }
143
- ${ utils . writeCargoLock }
62
+ ${ config . rust-cargo-lock . writeCargoLock }
144
63
'' ;
145
64
} ;
146
65
in {
@@ -154,24 +73,13 @@ in {
154
73
package-func . args = buildArgs ;
155
74
156
75
public = {
157
- meta = utils . getMeta pname version ;
76
+ inherit meta ;
158
77
} ;
159
78
160
79
deps = { nixpkgs , ...} : {
161
80
inherit
162
81
( nixpkgs )
163
- cargo
164
- fetchurl
165
- jq
166
- moreutils
167
- python3Packages
168
- runCommandLocal
169
82
rustPlatform
170
- writeText
171
- ;
172
- inherit
173
- ( nixpkgs . writers )
174
- writePython3
175
83
;
176
84
} ;
177
85
}
0 commit comments