Skip to content

Commit

Permalink
stdenv: re-add meta.repository
Browse files Browse the repository at this point in the history
  • Loading branch information
lolbinarycat committed Apr 9, 2024
1 parent 88c619a commit 16139a4
Show file tree
Hide file tree
Showing 2 changed files with 30 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
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

0 comments on commit 16139a4

Please sign in to comment.