fetchNextcloudApp: refactor for testing

staticdev 49548431 e27f6eba

Changed files
+31 -36
pkgs
build-support
fetchnextcloudapp
+27 -32
pkgs/build-support/fetchnextcloudapp/default.nix
···
...
}:
{
+
name ?
+
if appName == null || appVersion == null then null else "nextcloud-app-${appName}-${appVersion}",
url,
hash ? "",
sha256 ? "",
···
license,
patches ? [ ],
description ? null,
+
longDescription ? description,
homepage ? null,
maintainers ? [ ],
teams ? [ ],
unpack ? false, # whether to use fetchzip rather than fetchurl
}:
-
applyPatches (
-
{
-
inherit patches;
-
src = (if unpack then fetchzip else fetchurl) {
-
inherit
-
url
-
hash
-
sha256
-
sha512
-
;
-
meta = {
-
license = lib.licenses.${license};
-
longDescription = description;
-
inherit homepage maintainers teams;
-
}
-
// lib.optionalAttrs (description != null) {
-
longDescription = description;
-
}
-
// lib.optionalAttrs (homepage != null) {
-
inherit homepage;
-
};
+
applyPatches {
+
${if name == null then null else "name"} = name;
+
inherit patches;
+
+
src = (if unpack then fetchzip else fetchurl) {
+
inherit url;
+
${if hash == "" then null else "hash"} = hash;
+
${if sha256 == "" then null else "sha256"} = sha256;
+
${if sha512 == "" then null else "sha512"} = sha512;
+
+
meta = {
+
license = lib.licenses.${license};
+
${if description == null then null else "description"} = description;
+
${if longDescription == null then null else "longDescription"} = longDescription;
+
${if homepage == null then null else "homepage"} = homepage;
+
inherit maintainers teams;
};
-
prePatch = ''
-
if [ ! -f ./appinfo/info.xml ]; then
-
echo "appinfo/info.xml doesn't exist in $out, aborting!"
-
exit 1
-
fi
-
'';
-
}
-
// lib.optionalAttrs (appName != null && appVersion != null) {
-
name = "nextcloud-app-${appName}-${appVersion}";
-
}
-
)
+
};
+
prePatch = ''
+
if [ ! -f ./appinfo/info.xml ]; then
+
echo "appinfo/info.xml doesn't exist in $out, aborting!"
+
exit 1
+
fi
+
'';
+
}
+4 -4
pkgs/build-support/fetchnextcloudapp/tests.nix
···
}:
{
-
simple-sha512 = testers.invalidateFetcherByDrvHash (fetchNextcloudApp {
+
simple-sha512 = testers.invalidateFetcherByDrvHash fetchNextcloudApp {
appName = "phonetrack";
appVersion = "0.8.2";
license = "agpl3Plus";
sha512 = "f67902d1b48def9a244383a39d7bec95bb4215054963a9751f99dae9bd2f2740c02d2ef97b3b76d69a36fa95f8a9374dd049440b195f4dad2f0c4bca645de228";
url = "https://github.com/julien-nc/phonetrack/releases/download/v0.8.2/phonetrack-0.8.2.tar.gz";
-
});
-
simple-sha256 = testers.invalidateFetcherByDrvHash (fetchNextcloudApp {
+
};
+
simple-sha256 = testers.invalidateFetcherByDrvHash fetchNextcloudApp {
appName = "phonetrack";
appVersion = "0.8.2";
license = "agpl3Plus";
sha256 = "7c4252186e0ff8e0b97fc3d30131eeadd51bd2f9cc6aa321eb0c1c541f9572c0";
url = "https://github.com/julien-nc/phonetrack/releases/download/v0.8.2/phonetrack-0.8.2.tar.gz";
-
});
+
};
}