Skip to content

Commit

Permalink
stdenv: re-add meta.repository
Browse files Browse the repository at this point in the history
  • Loading branch information
binarycat committed Apr 5, 2024
1 parent 88c619a commit a95b4fb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
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
19 changes: 19 additions & 0 deletions pkgs/stdenv/generic/check-meta.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ let
concatMapStringsSep
concatStrings
findFirst
filter
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,10 @@ let
# -----
else { valid = "yes"; });

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

# 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 +464,15 @@ let
hasOutput = out: builtins.elem out outputs;
in
{
# get the default value for the meta.repository field.
# the fetchFrom* fetchers set src.meta.homepage
# NOTE: this will fail if src fails to eval, in that case either set meta.repository manually to prevent this default from being evaluated, or just make sure src doesn't fail to eval.
repository =
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

0 comments on commit a95b4fb

Please sign in to comment.