From 3ca9b9a8ad1b9dee2ec40eecca557f0578786b93 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Mon, 26 Sep 2022 20:32:33 +0200 Subject: [PATCH 1/2] fetchNextcloudApp: rewrite with fetchzip & applyPatches There are the following issues with the current implementation: * `fetchurl` with a tarball from GitHub appears to break occasionally because the tarballs are not necessarily reproducible. Because of that, `fetchFromGitHub` unpacks the tarball already because the contents are actually reproducible in contrast to the tarball. To have the same behavior here, we use `fetchzip` now (and `applyPatches` on top to apply additional patches if needed). * Fixes the way how patches are applied. Previously, when having patches for a git checkout of the app, these wouldn't apply because the `appname-version` prefix is missing. * Because all old hashes are broken with this, I added an evaluation check that breaks evaluation when using the old API (i.e. with `name`/`version` which are not needed anymore). --- .../fetchnextcloudapp/default.nix | 47 +++++++++---------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/pkgs/build-support/fetchnextcloudapp/default.nix b/pkgs/build-support/fetchnextcloudapp/default.nix index 1997c80c8a15..a7a3066ffab3 100644 --- a/pkgs/build-support/fetchnextcloudapp/default.nix +++ b/pkgs/build-support/fetchnextcloudapp/default.nix @@ -1,32 +1,27 @@ -{ stdenv, fetchurl, ... }: -{ name -, url -, version +{ stdenv, fetchzip, applyPatches, ... }: +{ url , sha256 , patches ? [ ] +, name ? null +, version ? null }: -stdenv.mkDerivation { - pname = "nc-app-${name}"; - inherit version patches; - - src = fetchurl { +if name != null || version != null then throw '' + `pkgs.fetchNextcloudApp` has been changed to use `fetchzip`. + To update, please + * remove `name`/`version` + * update the hash +'' +else applyPatches { + inherit patches; + src = fetchzip { inherit url sha256; + postFetch = '' + pushd $out &>/dev/null + if [ ! -f ./appinfo/info.xml ]; then + echo "appinfo/info.xml doesn't exist in $out, aborting!" + exit 1 + fi + popd &>/dev/null + ''; }; - - unpackPhase = '' - tar -xzpf $src - ''; - - installPhase = '' - approot="$(dirname $(dirname $(find -path '*/appinfo/info.xml' | head -n 1)))" - - if [ -d "$approot" ]; - then - mv "$approot/" $out - chmod -R a-w $out - else - echo "Could not find appinfo/info.xml" - exit 1; - fi - ''; } From d41b381310f5dcde1434b23406532f54ebdeea22 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sat, 1 Oct 2022 16:33:32 +0200 Subject: [PATCH 2/2] nixos/release-notes: document `fetchNextcloudApp` changes --- .../manual/from_md/release-notes/rl-2211.section.xml | 10 ++++++++++ nixos/doc/manual/release-notes/rl-2211.section.md | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml index cdf6e9999408..6e93f347c130 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml @@ -588,6 +588,16 @@ [ "lua54" "luau" ]. + + + pkgs.fetchNextcloudApp has been rewritten + to circumvent impurities in e.g. tarballs from GitHub and to + make it easier to apply patches. This means that your hashes + are out-of-date and the (previously required) attributes + name and version are no + longer accepted. + +
diff --git a/nixos/doc/manual/release-notes/rl-2211.section.md b/nixos/doc/manual/release-notes/rl-2211.section.md index 607e5cfeb4d4..37e8bfb8926a 100644 --- a/nixos/doc/manual/release-notes/rl-2211.section.md +++ b/nixos/doc/manual/release-notes/rl-2211.section.md @@ -199,6 +199,10 @@ Available as [services.patroni](options.html#opt-services.patroni.enable). - `stylua` no longer accepts `lua52Support` and `luauSupport` overrides, use `features` instead, which defaults to `[ "lua54" "luau" ]`. +- `pkgs.fetchNextcloudApp` has been rewritten to circumvent impurities in e.g. tarballs from GitHub and to make it easier to + apply patches. This means that your hashes are out-of-date and the (previously required) attributes `name` and `version` + are no longer accepted. + ## Other Notable Changes {#sec-release-22.11-notable-changes}