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
···
0
0
0
0
0
0
0
0
0
0
···
1
+
{ fetchzip }:
2
+
3
+
{ owner, repo, rev, name ? "source"
4
+
, ... # For hash agility
5
+
}@args: fetchzip ({
6
+
inherit name;
7
+
url = "https://bitbucket.org/${owner}/${repo}/get/${rev}.tar.gz";
8
+
meta.homepage = "https://bitbucket.org/${owner}/${repo}/";
9
+
extraPostFetch = ''rm -f "$out"/.hg_archival.txt''; # impure file; see #12002
10
+
} // removeAttrs args [ "owner" "repo" "rev" ]) // { inherit rev; }
+33
pkgs/build-support/fetchgithub/default.nix
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
{ lib, fetchgit, fetchzip }:
2
+
3
+
{ owner, repo, rev, name ? "source"
4
+
, fetchSubmodules ? false, private ? false
5
+
, githubBase ? "github.com", varPrefix ? null
6
+
, ... # For hash agility
7
+
}@args: assert private -> !fetchSubmodules;
8
+
let
9
+
baseUrl = "https://${githubBase}/${owner}/${repo}";
10
+
passthruAttrs = removeAttrs args [ "owner" "repo" "rev" "fetchSubmodules" "private" "githubBase" "varPrefix" ];
11
+
varBase = "NIX${if varPrefix == null then "" else "_${varPrefix}"}_GITHUB_PRIVATE_";
12
+
# We prefer fetchzip in cases we don't need submodules as the hash
13
+
# is more stable in that case.
14
+
fetcher = if fetchSubmodules then fetchgit else fetchzip;
15
+
privateAttrs = lib.optionalAttrs private {
16
+
netrcPhase = ''
17
+
if [ -z "''$${varBase}USERNAME" -o -z "''$${varBase}PASSWORD" ]; then
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
+
exit 1
20
+
fi
21
+
cat > netrc <<EOF
22
+
machine ${githubBase}
23
+
login ''$${varBase}USERNAME
24
+
password ''$${varBase}PASSWORD
25
+
EOF
26
+
'';
27
+
netrcImpureEnvVars = [ "${varBase}USERNAME" "${varBase}PASSWORD" ];
28
+
};
29
+
fetcherArgs = (if fetchSubmodules
30
+
then { inherit rev fetchSubmodules; url = "${baseUrl}.git"; }
31
+
else ({ url = "${baseUrl}/archive/${rev}.tar.gz"; } // privateAttrs)
32
+
) // passthruAttrs // { inherit name; };
33
+
in fetcher fetcherArgs // { meta.homepage = baseUrl; inherit rev; }
+10
pkgs/build-support/fetchgitlab/default.nix
···
0
0
0
0
0
0
0
0
0
0
···
1
+
{ fetchzip, lib }:
2
+
3
+
# gitlab example
4
+
{ owner, repo, rev, domain ? "gitlab.com", name ? "source", group ? null
5
+
, ... # For hash agility
6
+
}@args: fetchzip ({
7
+
inherit name;
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
+
meta.homepage = "https://${domain}/${lib.optionalString (group != null) "${group}/"}${owner}/${repo}/";
10
+
} // removeAttrs args [ "domain" "owner" "group" "repo" "rev" ]) // { inherit rev; }
+10
pkgs/build-support/fetchrepoorcz/default.nix
···
0
0
0
0
0
0
0
0
0
0
···
1
+
{ fetchzip }:
2
+
3
+
# gitweb example, snapshot support is optional in gitweb
4
+
{ repo, rev, name ? "source"
5
+
, ... # For hash agility
6
+
}@args: fetchzip ({
7
+
inherit name;
8
+
url = "https://repo.or.cz/${repo}.git/snapshot/${rev}.tar.gz";
9
+
meta.homepage = "https://repo.or.cz/${repo}.git/";
10
+
} // removeAttrs args [ "repo" "rev" ]) // { inherit rev; }
+10
pkgs/build-support/fetchsavannah/default.nix
···
0
0
0
0
0
0
0
0
0
0
···
1
+
{ fetchzip }:
2
+
3
+
# cgit example, snapshot support is optional in cgit
4
+
{ repo, rev, name ? "source"
5
+
, ... # For hash agility
6
+
}@args: fetchzip ({
7
+
inherit name;
8
+
url = "https://git.savannah.gnu.org/cgit/${repo}.git/snapshot/${repo}-${rev}.tar.gz";
9
+
meta.homepage = "https://git.savannah.gnu.org/cgit/${repo}.git/";
10
+
} // removeAttrs args [ "repo" "rev" ]) // { inherit rev; }
+5
-68
pkgs/top-level/all-packages.nix
···
261
262
fetchCrate = callPackage ../build-support/rust/fetchcrate.nix { };
263
264
-
fetchFromGitHub = {
265
-
owner, repo, rev, name ? "source",
266
-
fetchSubmodules ? false, private ? false,
267
-
githubBase ? "github.com", varPrefix ? null,
268
-
... # For hash agility
269
-
}@args: assert private -> !fetchSubmodules;
270
-
let
271
-
baseUrl = "https://${githubBase}/${owner}/${repo}";
272
-
passthruAttrs = removeAttrs args [ "owner" "repo" "rev" "fetchSubmodules" "private" "githubBase" "varPrefix" ];
273
-
varBase = "NIX${if varPrefix == null then "" else "_${varPrefix}"}_GITHUB_PRIVATE_";
274
-
# We prefer fetchzip in cases we don't need submodules as the hash
275
-
# is more stable in that case.
276
-
fetcher = if fetchSubmodules then fetchgit else fetchzip;
277
-
privateAttrs = lib.optionalAttrs private {
278
-
netrcPhase = ''
279
-
if [ -z "''$${varBase}USERNAME" -o -z "''$${varBase}PASSWORD" ]; then
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
-
exit 1
282
-
fi
283
-
cat > netrc <<EOF
284
-
machine ${githubBase}
285
-
login ''$${varBase}USERNAME
286
-
password ''$${varBase}PASSWORD
287
-
EOF
288
-
'';
289
-
netrcImpureEnvVars = [ "${varBase}USERNAME" "${varBase}PASSWORD" ];
290
-
};
291
-
fetcherArgs = (if fetchSubmodules
292
-
then { inherit rev fetchSubmodules; url = "${baseUrl}.git"; }
293
-
else ({ url = "${baseUrl}/archive/${rev}.tar.gz"; } // privateAttrs)
294
-
) // passthruAttrs // { inherit name; };
295
-
in fetcher fetcherArgs // { meta.homepage = baseUrl; inherit rev; };
296
297
-
fetchFromBitbucket = {
298
-
owner, repo, rev, name ? "source",
299
-
... # For hash agility
300
-
}@args: fetchzip ({
301
-
inherit name;
302
-
url = "https://bitbucket.org/${owner}/${repo}/get/${rev}.tar.gz";
303
-
meta.homepage = "https://bitbucket.org/${owner}/${repo}/";
304
-
extraPostFetch = ''rm -f "$out"/.hg_archival.txt''; # impure file; see #12002
305
-
} // removeAttrs args [ "owner" "repo" "rev" ]) // { inherit rev; };
306
307
-
# cgit example, snapshot support is optional in cgit
308
-
fetchFromSavannah = {
309
-
repo, rev, name ? "source",
310
-
... # For hash agility
311
-
}@args: fetchzip ({
312
-
inherit name;
313
-
url = "https://git.savannah.gnu.org/cgit/${repo}.git/snapshot/${repo}-${rev}.tar.gz";
314
-
meta.homepage = "https://git.savannah.gnu.org/cgit/${repo}.git/";
315
-
} // removeAttrs args [ "repo" "rev" ]) // { inherit rev; };
316
317
-
# gitlab example
318
-
fetchFromGitLab = {
319
-
owner, repo, rev, domain ? "gitlab.com", name ? "source", group ? null,
320
-
... # For hash agility
321
-
}@args: fetchzip ({
322
-
inherit name;
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
-
meta.homepage = "https://${domain}/${lib.optionalString (group != null) "${group}/"}${owner}/${repo}/";
325
-
} // removeAttrs args [ "domain" "owner" "group" "repo" "rev" ]) // { inherit rev; };
326
327
-
# gitweb example, snapshot support is optional in gitweb
328
-
fetchFromRepoOrCz = {
329
-
repo, rev, name ? "source",
330
-
... # For hash agility
331
-
}@args: fetchzip ({
332
-
inherit name;
333
-
url = "https://repo.or.cz/${repo}.git/snapshot/${rev}.tar.gz";
334
-
meta.homepage = "https://repo.or.cz/${repo}.git/";
335
-
} // removeAttrs args [ "repo" "rev" ]) // { inherit rev; };
336
337
fetchNuGet = callPackage ../build-support/fetchnuget { };
338
buildDotnetPackage = callPackage ../build-support/build-dotnet-package { };
···
261
262
fetchCrate = callPackage ../build-support/rust/fetchcrate.nix { };
263
264
+
fetchFromGitHub = callPackage ../build-support/fetchgithub {};
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
265
266
+
fetchFromBitbucket = callPackage ../build-support/fetchbitbucket {};
0
0
0
0
0
0
0
0
267
268
+
fetchFromSavannah = callPackage ../build-support/fetchsavannah {};
0
0
0
0
0
0
0
0
269
270
+
fetchFromGitLab = callPackage ../build-support/fetchgitlab {};
0
0
0
0
0
0
0
0
271
272
+
fetchFromRepoOrCz = callPackage ../build-support/fetchrepoorcz {};
0
0
0
0
0
0
0
0
273
274
fetchNuGet = callPackage ../build-support/fetchnuget { };
275
buildDotnetPackage = callPackage ../build-support/build-dotnet-package { };