nixpkgs/pkgs/servers/nextcloud/packages/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
975 B
Nix
Raw Normal View History

2022-10-23 14:54:25 +02:00
# Source: https://git.helsinki.tools/helsinki-systems/wp4nix/-/blob/master/default.nix
# Licensed under: MIT
# Slightly modified
{ lib, pkgs, newScope, apps }:
let packages = self:
let
generatedJson = {
inherit apps;
};
nextcloud*Packages: expose proper license information This change makes sure that each Nextcloud plugin installed provides a `meta` section with proper license information. Unfortunately, the metadata from the appstore is useless for this purpose since it doesn't differentiate between e.g. AGPL 3.x and AGPL 3.x or any later version. In fact, this isn't consistent between their software, e.g. `bookmarks` has `agpl3Plus` according to the files' headers[1] whereas `twofactor_nextcloud_notification` is AGPL 3 only[2]. I don't think there's any trivial and reasonable way to retrieve this information programatically, so I decided to change the format of `nextcloud-apps.json`[3] to also contain the license in the form of the license attribute we have in `lib/licenses.nix`, i.e. GNU AGPL 3 or later is `agpl3Plus`. I retrieved the information using the following approach: * go to the source code of $app at the revision we currently have packaged * check for a license identifier (does it specify the license only or the license "or any later version")? * first in `src/main.js` because most apps from Nextcloud itself used actual spdx identifiers in the frontend's source-code. * then in `lib/AppInfo/Application.php` which each Nextcloud app has. License changes should be updated accordingly when updating the apps. As with any other package in nixpkgs as well, this currently needs to be done manually (or as part of the review process)[4]. Also, I decided to change the `name` of the `applyPatches` derivation from `source-patched` to `nextcloud-app-${appName}-${appVersion}`. When deploying a lot of apps (and probably displaying the diff using `nix store diff-closures` on deploy), the current output isn't very helpful. This is purely optional because I didn't want to break the interface of `fetchNextcloudApp` again. [1] https://github.com/nextcloud/bookmarks/blob/v13.1.0/lib/AppInfo/Application.php#L6 [2] https://github.com/nextcloud/twofactor_nextcloud_notification/blob/v3.7.0/lib/AppInfo/Application.php [3] This isn't really well-defined since it's preprocessed with `jq(1)` before passing the apps to nc4nix. [4] Though notable license changes (e.g. agpl -> gpl) would also pop up in the diff of <nextcloudversion>.json, so this is pretty easy to catch.
2023-08-20 12:30:34 +02:00
appBaseDefs = builtins.fromJSON (builtins.readFile ./nextcloud-apps.json);
2022-10-23 14:54:25 +02:00
in {
# Create a derivation from the official Nextcloud apps.
# This takes the data generated from the go tool.
nextcloud*Packages: expose proper license information This change makes sure that each Nextcloud plugin installed provides a `meta` section with proper license information. Unfortunately, the metadata from the appstore is useless for this purpose since it doesn't differentiate between e.g. AGPL 3.x and AGPL 3.x or any later version. In fact, this isn't consistent between their software, e.g. `bookmarks` has `agpl3Plus` according to the files' headers[1] whereas `twofactor_nextcloud_notification` is AGPL 3 only[2]. I don't think there's any trivial and reasonable way to retrieve this information programatically, so I decided to change the format of `nextcloud-apps.json`[3] to also contain the license in the form of the license attribute we have in `lib/licenses.nix`, i.e. GNU AGPL 3 or later is `agpl3Plus`. I retrieved the information using the following approach: * go to the source code of $app at the revision we currently have packaged * check for a license identifier (does it specify the license only or the license "or any later version")? * first in `src/main.js` because most apps from Nextcloud itself used actual spdx identifiers in the frontend's source-code. * then in `lib/AppInfo/Application.php` which each Nextcloud app has. License changes should be updated accordingly when updating the apps. As with any other package in nixpkgs as well, this currently needs to be done manually (or as part of the review process)[4]. Also, I decided to change the `name` of the `applyPatches` derivation from `source-patched` to `nextcloud-app-${appName}-${appVersion}`. When deploying a lot of apps (and probably displaying the diff using `nix store diff-closures` on deploy), the current output isn't very helpful. This is purely optional because I didn't want to break the interface of `fetchNextcloudApp` again. [1] https://github.com/nextcloud/bookmarks/blob/v13.1.0/lib/AppInfo/Application.php#L6 [2] https://github.com/nextcloud/twofactor_nextcloud_notification/blob/v3.7.0/lib/AppInfo/Application.php [3] This isn't really well-defined since it's preprocessed with `jq(1)` before passing the apps to nc4nix. [4] Though notable license changes (e.g. agpl -> gpl) would also pop up in the diff of <nextcloudversion>.json, so this is pretty easy to catch.
2023-08-20 12:30:34 +02:00
mkNextcloudDerivation = self.callPackage ({ }: { pname, data }:
2022-10-23 14:54:25 +02:00
pkgs.fetchNextcloudApp {
nextcloud*Packages: expose proper license information This change makes sure that each Nextcloud plugin installed provides a `meta` section with proper license information. Unfortunately, the metadata from the appstore is useless for this purpose since it doesn't differentiate between e.g. AGPL 3.x and AGPL 3.x or any later version. In fact, this isn't consistent between their software, e.g. `bookmarks` has `agpl3Plus` according to the files' headers[1] whereas `twofactor_nextcloud_notification` is AGPL 3 only[2]. I don't think there's any trivial and reasonable way to retrieve this information programatically, so I decided to change the format of `nextcloud-apps.json`[3] to also contain the license in the form of the license attribute we have in `lib/licenses.nix`, i.e. GNU AGPL 3 or later is `agpl3Plus`. I retrieved the information using the following approach: * go to the source code of $app at the revision we currently have packaged * check for a license identifier (does it specify the license only or the license "or any later version")? * first in `src/main.js` because most apps from Nextcloud itself used actual spdx identifiers in the frontend's source-code. * then in `lib/AppInfo/Application.php` which each Nextcloud app has. License changes should be updated accordingly when updating the apps. As with any other package in nixpkgs as well, this currently needs to be done manually (or as part of the review process)[4]. Also, I decided to change the `name` of the `applyPatches` derivation from `source-patched` to `nextcloud-app-${appName}-${appVersion}`. When deploying a lot of apps (and probably displaying the diff using `nix store diff-closures` on deploy), the current output isn't very helpful. This is purely optional because I didn't want to break the interface of `fetchNextcloudApp` again. [1] https://github.com/nextcloud/bookmarks/blob/v13.1.0/lib/AppInfo/Application.php#L6 [2] https://github.com/nextcloud/twofactor_nextcloud_notification/blob/v3.7.0/lib/AppInfo/Application.php [3] This isn't really well-defined since it's preprocessed with `jq(1)` before passing the apps to nc4nix. [4] Though notable license changes (e.g. agpl -> gpl) would also pop up in the diff of <nextcloudversion>.json, so this is pretty easy to catch.
2023-08-20 12:30:34 +02:00
appName = pname;
appVersion = data.version;
license = appBaseDefs.${pname};
inherit (data) url sha256 description homepage;
2022-10-23 14:54:25 +02:00
}) {};
nextcloud*Packages: expose proper license information This change makes sure that each Nextcloud plugin installed provides a `meta` section with proper license information. Unfortunately, the metadata from the appstore is useless for this purpose since it doesn't differentiate between e.g. AGPL 3.x and AGPL 3.x or any later version. In fact, this isn't consistent between their software, e.g. `bookmarks` has `agpl3Plus` according to the files' headers[1] whereas `twofactor_nextcloud_notification` is AGPL 3 only[2]. I don't think there's any trivial and reasonable way to retrieve this information programatically, so I decided to change the format of `nextcloud-apps.json`[3] to also contain the license in the form of the license attribute we have in `lib/licenses.nix`, i.e. GNU AGPL 3 or later is `agpl3Plus`. I retrieved the information using the following approach: * go to the source code of $app at the revision we currently have packaged * check for a license identifier (does it specify the license only or the license "or any later version")? * first in `src/main.js` because most apps from Nextcloud itself used actual spdx identifiers in the frontend's source-code. * then in `lib/AppInfo/Application.php` which each Nextcloud app has. License changes should be updated accordingly when updating the apps. As with any other package in nixpkgs as well, this currently needs to be done manually (or as part of the review process)[4]. Also, I decided to change the `name` of the `applyPatches` derivation from `source-patched` to `nextcloud-app-${appName}-${appVersion}`. When deploying a lot of apps (and probably displaying the diff using `nix store diff-closures` on deploy), the current output isn't very helpful. This is purely optional because I didn't want to break the interface of `fetchNextcloudApp` again. [1] https://github.com/nextcloud/bookmarks/blob/v13.1.0/lib/AppInfo/Application.php#L6 [2] https://github.com/nextcloud/twofactor_nextcloud_notification/blob/v3.7.0/lib/AppInfo/Application.php [3] This isn't really well-defined since it's preprocessed with `jq(1)` before passing the apps to nc4nix. [4] Though notable license changes (e.g. agpl -> gpl) would also pop up in the diff of <nextcloudversion>.json, so this is pretty easy to catch.
2023-08-20 12:30:34 +02:00
} // lib.mapAttrs (type: pkgs:
lib.makeExtensible (_: lib.mapAttrs (pname: data: self.mkNextcloudDerivation { inherit pname; inherit data; }) pkgs))
generatedJson;
2022-10-23 14:54:25 +02:00
in (lib.makeExtensible (_: (lib.makeScope newScope packages))).extend (selfNC: superNC: {})