tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
all-packages: move fetch* to pkgs/build-support/
Matthew Bauer
7 years ago
d16e0f8d
cb14f140
+78
-68
6 changed files
expand all
collapse all
unified
split
pkgs
build-support
fetchbitbucket
default.nix
fetchgithub
default.nix
fetchgitlab
default.nix
fetchrepoorcz
default.nix
fetchsavannah
default.nix
top-level
all-packages.nix
+10
pkgs/build-support/fetchbitbucket/default.nix
···
1
1
+
{ fetchzip }:
2
2
+
3
3
+
{ owner, repo, rev, name ? "source"
4
4
+
, ... # For hash agility
5
5
+
}@args: fetchzip ({
6
6
+
inherit name;
7
7
+
url = "https://bitbucket.org/${owner}/${repo}/get/${rev}.tar.gz";
8
8
+
meta.homepage = "https://bitbucket.org/${owner}/${repo}/";
9
9
+
extraPostFetch = ''rm -f "$out"/.hg_archival.txt''; # impure file; see #12002
10
10
+
} // removeAttrs args [ "owner" "repo" "rev" ]) // { inherit rev; }
+33
pkgs/build-support/fetchgithub/default.nix
···
1
1
+
{ lib, fetchgit, fetchzip }:
2
2
+
3
3
+
{ owner, repo, rev, name ? "source"
4
4
+
, fetchSubmodules ? false, private ? false
5
5
+
, githubBase ? "github.com", varPrefix ? null
6
6
+
, ... # For hash agility
7
7
+
}@args: assert private -> !fetchSubmodules;
8
8
+
let
9
9
+
baseUrl = "https://${githubBase}/${owner}/${repo}";
10
10
+
passthruAttrs = removeAttrs args [ "owner" "repo" "rev" "fetchSubmodules" "private" "githubBase" "varPrefix" ];
11
11
+
varBase = "NIX${if varPrefix == null then "" else "_${varPrefix}"}_GITHUB_PRIVATE_";
12
12
+
# We prefer fetchzip in cases we don't need submodules as the hash
13
13
+
# is more stable in that case.
14
14
+
fetcher = if fetchSubmodules then fetchgit else fetchzip;
15
15
+
privateAttrs = lib.optionalAttrs private {
16
16
+
netrcPhase = ''
17
17
+
if [ -z "''$${varBase}USERNAME" -o -z "''$${varBase}PASSWORD" ]; then
18
18
+
echo "Error: Private fetchFromGitHub requires the nix building process (nix-daemon in multi user mode) to have the ${varBase}USERNAME and ${varBase}PASSWORD env vars set." >&2
19
19
+
exit 1
20
20
+
fi
21
21
+
cat > netrc <<EOF
22
22
+
machine ${githubBase}
23
23
+
login ''$${varBase}USERNAME
24
24
+
password ''$${varBase}PASSWORD
25
25
+
EOF
26
26
+
'';
27
27
+
netrcImpureEnvVars = [ "${varBase}USERNAME" "${varBase}PASSWORD" ];
28
28
+
};
29
29
+
fetcherArgs = (if fetchSubmodules
30
30
+
then { inherit rev fetchSubmodules; url = "${baseUrl}.git"; }
31
31
+
else ({ url = "${baseUrl}/archive/${rev}.tar.gz"; } // privateAttrs)
32
32
+
) // passthruAttrs // { inherit name; };
33
33
+
in fetcher fetcherArgs // { meta.homepage = baseUrl; inherit rev; }
+10
pkgs/build-support/fetchgitlab/default.nix
···
1
1
+
{ fetchzip, lib }:
2
2
+
3
3
+
# gitlab example
4
4
+
{ owner, repo, rev, domain ? "gitlab.com", name ? "source", group ? null
5
5
+
, ... # For hash agility
6
6
+
}@args: fetchzip ({
7
7
+
inherit name;
8
8
+
url = "https://${domain}/api/v4/projects/${lib.optionalString (group != null) "${lib.replaceStrings ["."] ["%2E"] group}%2F"}${lib.replaceStrings ["."] ["%2E"] owner}%2F${lib.replaceStrings ["."] ["%2E"] repo}/repository/archive.tar.gz?sha=${rev}";
9
9
+
meta.homepage = "https://${domain}/${lib.optionalString (group != null) "${group}/"}${owner}/${repo}/";
10
10
+
} // removeAttrs args [ "domain" "owner" "group" "repo" "rev" ]) // { inherit rev; }
+10
pkgs/build-support/fetchrepoorcz/default.nix
···
1
1
+
{ fetchzip }:
2
2
+
3
3
+
# gitweb example, snapshot support is optional in gitweb
4
4
+
{ repo, rev, name ? "source"
5
5
+
, ... # For hash agility
6
6
+
}@args: fetchzip ({
7
7
+
inherit name;
8
8
+
url = "https://repo.or.cz/${repo}.git/snapshot/${rev}.tar.gz";
9
9
+
meta.homepage = "https://repo.or.cz/${repo}.git/";
10
10
+
} // removeAttrs args [ "repo" "rev" ]) // { inherit rev; }
+10
pkgs/build-support/fetchsavannah/default.nix
···
1
1
+
{ fetchzip }:
2
2
+
3
3
+
# cgit example, snapshot support is optional in cgit
4
4
+
{ repo, rev, name ? "source"
5
5
+
, ... # For hash agility
6
6
+
}@args: fetchzip ({
7
7
+
inherit name;
8
8
+
url = "https://git.savannah.gnu.org/cgit/${repo}.git/snapshot/${repo}-${rev}.tar.gz";
9
9
+
meta.homepage = "https://git.savannah.gnu.org/cgit/${repo}.git/";
10
10
+
} // removeAttrs args [ "repo" "rev" ]) // { inherit rev; }
+5
-68
pkgs/top-level/all-packages.nix
···
261
261
262
262
fetchCrate = callPackage ../build-support/rust/fetchcrate.nix { };
263
263
264
264
-
fetchFromGitHub = {
265
265
-
owner, repo, rev, name ? "source",
266
266
-
fetchSubmodules ? false, private ? false,
267
267
-
githubBase ? "github.com", varPrefix ? null,
268
268
-
... # For hash agility
269
269
-
}@args: assert private -> !fetchSubmodules;
270
270
-
let
271
271
-
baseUrl = "https://${githubBase}/${owner}/${repo}";
272
272
-
passthruAttrs = removeAttrs args [ "owner" "repo" "rev" "fetchSubmodules" "private" "githubBase" "varPrefix" ];
273
273
-
varBase = "NIX${if varPrefix == null then "" else "_${varPrefix}"}_GITHUB_PRIVATE_";
274
274
-
# We prefer fetchzip in cases we don't need submodules as the hash
275
275
-
# is more stable in that case.
276
276
-
fetcher = if fetchSubmodules then fetchgit else fetchzip;
277
277
-
privateAttrs = lib.optionalAttrs private {
278
278
-
netrcPhase = ''
279
279
-
if [ -z "''$${varBase}USERNAME" -o -z "''$${varBase}PASSWORD" ]; then
280
280
-
echo "Error: Private fetchFromGitHub requires the nix building process (nix-daemon in multi user mode) to have the ${varBase}USERNAME and ${varBase}PASSWORD env vars set." >&2
281
281
-
exit 1
282
282
-
fi
283
283
-
cat > netrc <<EOF
284
284
-
machine ${githubBase}
285
285
-
login ''$${varBase}USERNAME
286
286
-
password ''$${varBase}PASSWORD
287
287
-
EOF
288
288
-
'';
289
289
-
netrcImpureEnvVars = [ "${varBase}USERNAME" "${varBase}PASSWORD" ];
290
290
-
};
291
291
-
fetcherArgs = (if fetchSubmodules
292
292
-
then { inherit rev fetchSubmodules; url = "${baseUrl}.git"; }
293
293
-
else ({ url = "${baseUrl}/archive/${rev}.tar.gz"; } // privateAttrs)
294
294
-
) // passthruAttrs // { inherit name; };
295
295
-
in fetcher fetcherArgs // { meta.homepage = baseUrl; inherit rev; };
264
264
+
fetchFromGitHub = callPackage ../build-support/fetchgithub {};
296
265
297
297
-
fetchFromBitbucket = {
298
298
-
owner, repo, rev, name ? "source",
299
299
-
... # For hash agility
300
300
-
}@args: fetchzip ({
301
301
-
inherit name;
302
302
-
url = "https://bitbucket.org/${owner}/${repo}/get/${rev}.tar.gz";
303
303
-
meta.homepage = "https://bitbucket.org/${owner}/${repo}/";
304
304
-
extraPostFetch = ''rm -f "$out"/.hg_archival.txt''; # impure file; see #12002
305
305
-
} // removeAttrs args [ "owner" "repo" "rev" ]) // { inherit rev; };
266
266
+
fetchFromBitbucket = callPackage ../build-support/fetchbitbucket {};
306
267
307
307
-
# cgit example, snapshot support is optional in cgit
308
308
-
fetchFromSavannah = {
309
309
-
repo, rev, name ? "source",
310
310
-
... # For hash agility
311
311
-
}@args: fetchzip ({
312
312
-
inherit name;
313
313
-
url = "https://git.savannah.gnu.org/cgit/${repo}.git/snapshot/${repo}-${rev}.tar.gz";
314
314
-
meta.homepage = "https://git.savannah.gnu.org/cgit/${repo}.git/";
315
315
-
} // removeAttrs args [ "repo" "rev" ]) // { inherit rev; };
268
268
+
fetchFromSavannah = callPackage ../build-support/fetchsavannah {};
316
269
317
317
-
# gitlab example
318
318
-
fetchFromGitLab = {
319
319
-
owner, repo, rev, domain ? "gitlab.com", name ? "source", group ? null,
320
320
-
... # For hash agility
321
321
-
}@args: fetchzip ({
322
322
-
inherit name;
323
323
-
url = "https://${domain}/api/v4/projects/${lib.optionalString (group != null) "${lib.replaceStrings ["."] ["%2E"] group}%2F"}${lib.replaceStrings ["."] ["%2E"] owner}%2F${lib.replaceStrings ["."] ["%2E"] repo}/repository/archive.tar.gz?sha=${rev}";
324
324
-
meta.homepage = "https://${domain}/${lib.optionalString (group != null) "${group}/"}${owner}/${repo}/";
325
325
-
} // removeAttrs args [ "domain" "owner" "group" "repo" "rev" ]) // { inherit rev; };
270
270
+
fetchFromGitLab = callPackage ../build-support/fetchgitlab {};
326
271
327
327
-
# gitweb example, snapshot support is optional in gitweb
328
328
-
fetchFromRepoOrCz = {
329
329
-
repo, rev, name ? "source",
330
330
-
... # For hash agility
331
331
-
}@args: fetchzip ({
332
332
-
inherit name;
333
333
-
url = "https://repo.or.cz/${repo}.git/snapshot/${rev}.tar.gz";
334
334
-
meta.homepage = "https://repo.or.cz/${repo}.git/";
335
335
-
} // removeAttrs args [ "repo" "rev" ]) // { inherit rev; };
272
272
+
fetchFromRepoOrCz = callPackage ../build-support/fetchrepoorcz {};
336
273
337
274
fetchNuGet = callPackage ../build-support/fetchnuget { };
338
275
buildDotnetPackage = callPackage ../build-support/build-dotnet-package { };