
This patch adds `lib.repoRevToName` function that generalizes away most of the code used for derivation name generation by `fetch*` functions (`fetchzip`, `fetchFromGitHub`, etc, except those which are delayed until latter commits for mass-rebuild reasons). It's first argument controls how the resulting name will look (see below). Since `lib` has no equivalent of Nixpkgs' `config`, this patch adds `config.fetchedSourceNameDefault` option to Nixpkgs and then re-exposes `lib.repoRevToName config.fetchedSourceNameDefault` expression as `pkgs.repoRevToNameMaybe` which is then used in `fetch*` derivations. The result is that different values of `config.fetchedSourceNameDefault` now control how the `src` derivations produced by `fetch*` functions are to be named, e.g.: - `fetchedSourceNameDefault = "source"` (the default): ``` $ nix-instantiate -A fuse.src /nix/store/<hash>-source.drv ``` - `fetchedSourceNameDefault = "versioned"`: ``` $ nix-instantiate -A fuse.src /nix/store/<hash>-libfuse-2.9.9-source.drv ``` - `fetchedSourceNameDefault = "full"`: ``` $ nix-instantiate -A fuse.src /nix/store/<hash>-libfuse-2.9.9-github-source.drv ``` See the documentation of `config.fetchedSourceNameDefault` for more info.
43 lines
699 B
Nix
43 lines
699 B
Nix
{
|
|
fetchzip,
|
|
repoRevToNameMaybe,
|
|
lib,
|
|
}:
|
|
|
|
lib.makeOverridable (
|
|
{
|
|
url,
|
|
rev ? null,
|
|
tag ? null,
|
|
name ? repoRevToNameMaybe url (lib.revOrTag rev tag) "gitiles",
|
|
...
|
|
}@args:
|
|
|
|
assert (
|
|
lib.assertMsg (lib.xor (tag == null) (
|
|
rev == null
|
|
)) "fetchFromGitiles requires one of either `rev` or `tag` to be provided (not both)."
|
|
);
|
|
|
|
let
|
|
realrev = (if tag != null then "refs/tags/" + tag else rev);
|
|
in
|
|
|
|
fetchzip (
|
|
{
|
|
inherit name;
|
|
url = "${url}/+archive/${realrev}.tar.gz";
|
|
stripRoot = false;
|
|
meta.homepage = url;
|
|
}
|
|
// removeAttrs args [
|
|
"url"
|
|
"tag"
|
|
"rev"
|
|
]
|
|
)
|
|
// {
|
|
inherit rev tag;
|
|
}
|
|
)
|