Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdenv: re-add meta.repository (resurrected) #301947

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/stdenv/meta.chapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ Release branch. Used to specify that a package is not going to receive updates t

The package’s homepage. Example: `https://www.gnu.org/software/hello/manual/`

### `repository` {#var-meta-repository}

A webpage (or list of webpages) where the package's source code can be viewed. `https` links are preferred if available. Automatically set to a default value if the package uses a `fetchFrom*` fetcher for its `src`. Example: `https://gitlab.freedesktop.org/libfprint/fprintd/`

### `downloadPage` {#var-meta-downloadPage}

The page where a link to the current version can be found. Example: `https://ftp.gnu.org/gnu/hello/`
Expand Down
26 changes: 26 additions & 0 deletions pkgs/stdenv/generic/check-meta.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ let
concatMapStrings
concatMapStringsSep
concatStrings
filter
findFirst
head
isDerivation
length
concatMap
Expand Down Expand Up @@ -303,6 +305,10 @@ let
(listOf str)
str
];
repository = union [
(listOf str)
str
];
downloadPage = str;
changelog = union [
(listOf str)
Expand Down Expand Up @@ -440,6 +446,15 @@ let
# -----
else { valid = "yes"; });

unlist = list:
if length list == 1
then head list
else list;

valOrEmpty = res:
if res.success
then res.value
else [];

# The meta attribute is passed in the resulting attribute set,
# but it's not part of the actual derivation, i.e., it's not
Expand All @@ -454,6 +469,17 @@ let
hasOutput = out: builtins.elem out outputs;
in
{
# get the default value for the meta.repository field.
# the fetchFrom* fetchers set src.meta.homepage
# tryEval will catch any throw-class errors, abort-class errors during
# evaluation are bugs and should be fixed.
repository =
valOrEmpty (builtins.tryEval (
if attrs ? src.meta.homepage
then attrs.src.meta.homepage
else if attrs ? srcs && isList attrs.srcs
then unlist (map (src: src.meta.homepage) (filter (src: src ? meta.homepage) attrs.srcs))
else []));
# `name` derivation attribute includes cross-compilation cruft,
# is under assert, and is sanitized.
# Let's have a clean always accessible version here.
Expand Down