about summary refs log tree commit diff
path: root/pkgs/desktops/gnome/extensions/default.nix
blob: 89f5edb5f7bf1aae99e609d0ce05faecbe21cd5d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
{ lib
, callPackage
, callPackages
, config
}:
let
  buildShellExtension = callPackage ./buildGnomeExtension.nix { };

  # Index of all scraped extensions (with supported versions)
  extensionsIndex = lib.importJSON ./extensions.json;

  # A list of UUIDs that have the same pname and we need to rename them
  extensionRenames = import ./extensionRenames.nix;

  # Take all extensions from the index that match the gnome version, build them and put them into a list of derivations
  produceExtensionsList = shell-version:
    lib.trivial.pipe extensionsIndex [
      # Does a given extension match our current shell version?
      (builtins.filter
        (extension: (builtins.hasAttr shell-version extension."shell_version_map"))
      )
      # Take in an `extension` object from the JSON and transform it into the correct args to call `buildShellExtension`
      (map
        (extension: {
          inherit (extension) uuid name description link pname;
          inherit (extension.shell_version_map.${shell-version}) version sha256 metadata;
        })
      )
      # Build them
      (map buildShellExtension)
    ];

  # Map the list of extensions to an attrset based on the UUID as key
  mapUuidNames = extensions:
    lib.trivial.pipe extensions [
      (map (extension: lib.nameValuePair extension.extensionUuid extension))
      builtins.listToAttrs
      (attrs: attrs // { __attrsFailEvaluation = true; })
    ];

  # Map the list of extensions to an attrset based on the pname as key, which is more human readable than the UUID
  # We also take care of conflict renaming in here
  mapReadableNames = extensionsList: lib.trivial.pipe extensionsList [
    # Filter out all extensions that map to null
    (lib.filter (extension:
      !(
        (builtins.hasAttr extension.extensionUuid extensionRenames)
        && ((builtins.getAttr extension.extensionUuid extensionRenames) == null)
      )
    ))
    # Map all extensions to their pname, with potential overwrites
    (map (extension:
      lib.nameValuePair (extensionRenames.${extension.extensionUuid} or extension.extensionPortalSlug) extension
    ))
    builtins.listToAttrs
  ];

in rec {
  # Remember to import all these in all-packages.nix
  gnome38Extensions = mapUuidNames (produceExtensionsList "38");
  gnome40Extensions = mapUuidNames (produceExtensionsList "40");
  gnome41Extensions = mapUuidNames (produceExtensionsList "41");
  gnome42Extensions = mapUuidNames (produceExtensionsList "42");
  gnome43Extensions = mapUuidNames (produceExtensionsList "43");
  gnome44Extensions = mapUuidNames (produceExtensionsList "44");
  gnome45Extensions = mapUuidNames (produceExtensionsList "45");

  # Keep the last three versions in here
  gnomeExtensions = lib.trivial.pipe (gnome43Extensions // gnome44Extensions // gnome45Extensions) [
    (v: builtins.removeAttrs v [ "__attrsFailEvaluation" ])
    # Apply some custom patches for automatically packaged extensions
    (callPackage ./extensionOverrides.nix {})
    # Add all manually packaged extensions
    (extensions: extensions // (callPackages ./manuallyPackaged.nix {}))
    # Map the extension UUIDs to readable names
    (lib.attrValues)
    (mapReadableNames)
    # Add some aliases
    (extensions: extensions // lib.optionalAttrs config.allowAliases {
      unite-shell = gnomeExtensions.unite; # added 2021-01-19
      arc-menu = gnomeExtensions.arcmenu; # added 2021-02-14
      disable-unredirect = gnomeExtensions.disable-unredirect-fullscreen-windows; # added 2021-11-20

      icon-hider = throw "gnomeExtensions.icon-hider was removed on 2024-03-15. The extension has not received any updates since 2020/3.34.";
      nohotcorner = throw "gnomeExtensions.nohotcorner removed since 2019-10-09: Since 3.34, it is a part of GNOME Shell configurable through GNOME Tweaks.";
      mediaplayer = throw "gnomeExtensions.mediaplayer deprecated since 2019-09-23: retired upstream https://github.com/JasonLG1979/gnome-shell-extensions-mediaplayer/blob/master/README.md";
      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.";
    })
    # Export buildShellExtension function
    (extensions: extensions // { inherit buildShellExtension; })
    # Make the set "public"
    lib.recurseIntoAttrs
  ];

}