1{ lib
2, callPackage
3, callPackages
4, config
5}:
6let
7 buildShellExtension = callPackage ./buildGnomeExtension.nix { };
8
9 # Index of all scraped extensions (with supported versions)
10 extensionsIndex = lib.importJSON ./extensions.json;
11
12 # A list of UUIDs that have the same pname and we need to rename them
13 extensionRenames = import ./extensionRenames.nix;
14
15 # Take all extensions from the index that match the gnome version, build them and put them into a list of derivations
16 produceExtensionsList = shell-version:
17 lib.trivial.pipe extensionsIndex [
18 # Does a given extension match our current shell version?
19 (builtins.filter
20 (extension: (builtins.hasAttr shell-version extension."shell_version_map"))
21 )
22 # Take in an `extension` object from the JSON and transform it into the correct args to call `buildShellExtension`
23 (map
24 (extension: {
25 inherit (extension) uuid name description link pname;
26 inherit (extension.shell_version_map.${shell-version}) version sha256 metadata;
27 })
28 )
29 # Build them
30 (map buildShellExtension)
31 ];
32
33 # Map the list of extensions to an attrset based on the UUID as key
34 mapUuidNames = extensions:
35 lib.trivial.pipe extensions [
36 (map (extension: lib.nameValuePair extension.extensionUuid extension))
37 builtins.listToAttrs
38 ];
39
40 # Map the list of extensions to an attrset based on the pname as key, which is more human readable than the UUID
41 # We also take care of conflict renaming in here
42 mapReadableNames = extensionsList: lib.trivial.pipe extensionsList [
43 # Filter out all extensions that map to null
44 (lib.filter (extension:
45 !(
46 (builtins.hasAttr extension.extensionUuid extensionRenames)
47 && ((builtins.getAttr extension.extensionUuid extensionRenames) == null)
48 )
49 ))
50 # Map all extensions to their pname, with potential overwrites
51 (map (extension:
52 lib.nameValuePair (extensionRenames.${extension.extensionUuid} or extension.extensionPortalSlug) extension
53 ))
54 builtins.listToAttrs
55 ];
56
57in rec {
58 # Remember to import all these in all-packages.nix
59 gnome38Extensions = mapUuidNames (produceExtensionsList "38");
60 gnome40Extensions = mapUuidNames (produceExtensionsList "40");
61 gnome41Extensions = mapUuidNames (produceExtensionsList "41");
62 gnome42Extensions = mapUuidNames (produceExtensionsList "42");
63 gnome43Extensions = mapUuidNames (produceExtensionsList "43");
64 gnome44Extensions = mapUuidNames (produceExtensionsList "44");
65
66 # Keep the last three versions in here
67 gnomeExtensions = lib.trivial.pipe (gnome42Extensions // gnome43Extensions // gnome44Extensions) [
68 # Apply some custom patches for automatically packaged extensions
69 (callPackage ./extensionOverrides.nix {})
70 # Add all manually packaged extensions
71 (extensions: extensions // (callPackages ./manuallyPackaged.nix {}))
72 # Map the extension UUIDs to readable names
73 (lib.attrValues)
74 (mapReadableNames)
75 # Add some aliases
76 (extensions: extensions // lib.optionalAttrs config.allowAliases {
77 unite-shell = gnomeExtensions.unite; # added 2021-01-19
78 arc-menu = gnomeExtensions.arcmenu; # added 2021-02-14
79 disable-unredirect = gnomeExtensions.disable-unredirect-fullscreen-windows; # added 2021-11-20
80
81 nohotcorner = throw "gnomeExtensions.nohotcorner removed since 2019-10-09: Since 3.34, it is a part of GNOME Shell configurable through GNOME Tweaks.";
82 mediaplayer = throw "gnomeExtensions.mediaplayer deprecated since 2019-09-23: retired upstream https://github.com/JasonLG1979/gnome-shell-extensions-mediaplayer/blob/master/README.md";
83 remove-dropdown-arrows = throw "gnomeExtensions.remove-dropdown-arrows removed since 2021-05-25: The extensions has not seen an update sine GNOME 3.34. Furthermore, the functionality it provides is obsolete as of GNOME 40.";
84 })
85 # Export buildShellExtension function
86 (extensions: extensions // { inherit buildShellExtension; })
87 # Make the set "public"
88 lib.recurseIntoAttrs
89 ];
90}