From 2196fed2b641f24b838b31d519d00cb622b495eb Mon Sep 17 00:00:00 2001 From: staticdev Date: Tue, 26 Aug 2025 22:15:57 +0200 Subject: [PATCH 1/3] fetchNextcloudApp: add sha512 --- nixos/modules/services/web-apps/nextcloud.nix | 7 +++--- .../fetchnextcloudapp/default.nix | 9 +++++++- .../build-support/fetchnextcloudapp/tests.nix | 22 +++++++++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 pkgs/build-support/fetchnextcloudapp/tests.nix diff --git a/nixos/modules/services/web-apps/nextcloud.nix b/nixos/modules/services/web-apps/nextcloud.nix index 658666680340..eac2d9622c4e 100644 --- a/nixos/modules/services/web-apps/nextcloud.nix +++ b/nixos/modules/services/web-apps/nextcloud.nix @@ -391,9 +391,10 @@ in inherit (pkgs.nextcloud31Packages.apps) mail calendar contacts; phonetrack = pkgs.fetchNextcloudApp { name = "phonetrack"; - sha256 = "0qf366vbahyl27p9mshfma1as4nvql6w75zy2zk5xwwbp343vsbc"; - url = "https://gitlab.com/eneiluj/phonetrack-oc/-/wikis/uploads/931aaaf8dca24bf31a7e169a83c17235/phonetrack-0.6.9.tar.gz"; - version = "0.6.9"; + license = "agpl3Plus"; + sha512 = "f67902d1b48def9a244383a39d7bec95bb4215054963a9751f99dae9bd2f2740c02d2ef97b3b76d69a36fa95f8a9374dd049440b195f4dad2f0c4bca645de228"; + url = "https://github.com/julien-nc/phonetrack/releases/download/v0.8.2/phonetrack-0.8.2.tar.gz"; + version = "0.8.2"; }; } ''; diff --git a/pkgs/build-support/fetchnextcloudapp/default.nix b/pkgs/build-support/fetchnextcloudapp/default.nix index 193b2b82a354..79f2edeae109 100644 --- a/pkgs/build-support/fetchnextcloudapp/default.nix +++ b/pkgs/build-support/fetchnextcloudapp/default.nix @@ -9,6 +9,7 @@ url, hash ? "", sha256 ? "", + sha512 ? "", appName ? null, appVersion ? null, license, @@ -23,7 +24,12 @@ applyPatches ( { inherit patches; src = (if unpack then fetchzip else fetchurl) { - inherit url hash sha256; + inherit + url + hash + sha256 + sha512 + ; meta = { license = lib.licenses.${license}; longDescription = description; @@ -42,6 +48,7 @@ applyPatches ( exit 1 fi ''; + # Optionally set name if appName and appVersion are provided } // lib.optionalAttrs (appName != null && appVersion != null) { name = "nextcloud-app-${appName}-${appVersion}"; diff --git a/pkgs/build-support/fetchnextcloudapp/tests.nix b/pkgs/build-support/fetchnextcloudapp/tests.nix new file mode 100644 index 000000000000..60696a84d69c --- /dev/null +++ b/pkgs/build-support/fetchnextcloudapp/tests.nix @@ -0,0 +1,22 @@ +{ + testers, + 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 { + 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"; + }); +} From e27f6eba7c2cad16ad5f10dae220830abb68321a Mon Sep 17 00:00:00 2001 From: staticdev Date: Wed, 27 Aug 2025 07:25:23 +0200 Subject: [PATCH 2/3] fetchNextcloudApp: add pkgs.test --- pkgs/build-support/fetchnextcloudapp/default.nix | 1 - pkgs/test/default.nix | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/fetchnextcloudapp/default.nix b/pkgs/build-support/fetchnextcloudapp/default.nix index 79f2edeae109..ab145892e3ab 100644 --- a/pkgs/build-support/fetchnextcloudapp/default.nix +++ b/pkgs/build-support/fetchnextcloudapp/default.nix @@ -48,7 +48,6 @@ applyPatches ( exit 1 fi ''; - # Optionally set name if appName and appVersion are provided } // lib.optionalAttrs (appName != null && appVersion != null) { name = "nextcloud-app-${appName}-${appVersion}"; diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix index 6314049ed0bc..dd1e30d09fa5 100644 --- a/pkgs/test/default.nix +++ b/pkgs/test/default.nix @@ -131,6 +131,9 @@ with pkgs; fetchDebianPatch = recurseIntoAttrs (callPackages ../build-support/fetchdebianpatch/tests.nix { }); fetchzip = recurseIntoAttrs (callPackages ../build-support/fetchzip/tests.nix { }); fetchgit = recurseIntoAttrs (callPackages ../build-support/fetchgit/tests.nix { }); + fetchNextcloudApp = recurseIntoAttrs ( + callPackages ../build-support/fetchnextcloudapp/tests.nix { } + ); fetchFromBitbucket = recurseIntoAttrs (callPackages ../build-support/fetchbitbucket/tests.nix { }); fetchFirefoxAddon = recurseIntoAttrs ( callPackages ../build-support/fetchfirefoxaddon/tests.nix { } From 49548431d7d7003c044a289cbbc71eeaaf4e40d0 Mon Sep 17 00:00:00 2001 From: staticdev Date: Wed, 27 Aug 2025 18:46:51 +0200 Subject: [PATCH 3/3] fetchNextcloudApp: refactor for testing --- .../fetchnextcloudapp/default.nix | 59 +++++++++---------- .../build-support/fetchnextcloudapp/tests.nix | 8 +-- 2 files changed, 31 insertions(+), 36 deletions(-) diff --git a/pkgs/build-support/fetchnextcloudapp/default.nix b/pkgs/build-support/fetchnextcloudapp/default.nix index ab145892e3ab..138ac8fb10cf 100644 --- a/pkgs/build-support/fetchnextcloudapp/default.nix +++ b/pkgs/build-support/fetchnextcloudapp/default.nix @@ -6,6 +6,8 @@ ... }: { + name ? + if appName == null || appVersion == null then null else "nextcloud-app-${appName}-${appVersion}", url, hash ? "", sha256 ? "", @@ -15,41 +17,34 @@ 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 + ''; +} diff --git a/pkgs/build-support/fetchnextcloudapp/tests.nix b/pkgs/build-support/fetchnextcloudapp/tests.nix index 60696a84d69c..38f3db68e106 100644 --- a/pkgs/build-support/fetchnextcloudapp/tests.nix +++ b/pkgs/build-support/fetchnextcloudapp/tests.nix @@ -5,18 +5,18 @@ }: { - 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"; - }); + }; }