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 4, 2024
1 parent 7e1443a commit 57534a2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 27 deletions.
3 changes: 1 addition & 2 deletions pkgs/development/coq-modules/serapi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ in
if version == "8.11.0+0.11.1" then version
else builtins.replaceStrings [ "+" ] [ "." ] version
}.tbz";
# abort/syntax error will fail package set eval, but throw is "fine"
sha256 = release."${version}".sha256 or (throw "Unknown version '${version}'");
sha256 = release."${version}".sha256;
};

patches =
Expand Down
44 changes: 19 additions & 25 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 @@ -295,11 +297,11 @@ let
(listOf str)
str
];
downloadPage = str;
repository = union [
(listOf str)
str
];
downloadPage = str;
changelog = union [
(listOf str)
str
Expand Down Expand Up @@ -436,6 +438,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 @@ -447,30 +453,18 @@ let
commonMeta = { validity, attrs, pos ? null, references ? [ ] }:
let
outputs = attrs.outputs or [ "out" ];
in
optionalAttrs (attrs ? src.meta.homepage || attrs ? srcs && isList attrs.srcs && any (src: src ? meta.homepage) attrs.srcs) {
# should point to an http-browsable source tree, if available.
# fetchers like fetchFromGitHub set it automatically.
# this could be handled a lot easier if we nulled it instead
# of having it be undefined, but that wouldn't match the
# other attributes.
repository = let
getSrcs = attrs:
if attrs ? src
then
[ attrs.src ]
else
lib.filter (src: src ? meta.homepage) attrs.srcs;
getHomePages = srcs: map (src: src.meta.homepage) srcs;
unlist = list:
if lib.length list == 1
then
lib.elemAt list 0
else
list;
in
unlist (getHomePages (getSrcs attrs));
} // {
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 57534a2

Please sign in to comment.