From 2c063fe250e019a44eba31e4f7857d0e35065b5b Mon Sep 17 00:00:00 2001 From: piegames Date: Wed, 8 Sep 2021 22:49:05 +0200 Subject: [PATCH] gnomeExtensions: add patch framework It's like Haskell's overlay system, but way more primitive. We simply pre-define some package overrides that are required for an automatically packaged extension to work. Ideally, all (or almost all) currently manually pacakged extensions will work this way. Since these are mostly just a few lines each, there is no need to split this up into a lot of small files. --- .../gnome/extensions/buildGnomeExtension.nix | 7 +++++-- pkgs/desktops/gnome/extensions/default.nix | 21 ++++++++++++------- .../gnome/extensions/extensionPatches.nix | 14 +++++++++++++ 3 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 pkgs/desktops/gnome/extensions/extensionPatches.nix diff --git a/pkgs/desktops/gnome/extensions/buildGnomeExtension.nix b/pkgs/desktops/gnome/extensions/buildGnomeExtension.nix index 3be7f5c8789a..d661c853bbc1 100644 --- a/pkgs/desktops/gnome/extensions/buildGnomeExtension.nix +++ b/pkgs/desktops/gnome/extensions/buildGnomeExtension.nix @@ -36,9 +36,12 @@ let echo "${metadata}" | base64 --decode > $out/metadata.json ''; }; - buildCommand = '' + dontBuild = true; + installPhase = '' + runHook preInstall mkdir -p $out/share/gnome-shell/extensions/ - cp -r -T $src $out/share/gnome-shell/extensions/${uuid} + cp -r -T . $out/share/gnome-shell/extensions/${uuid} + runHook postInstall ''; meta = { description = builtins.head (lib.splitString "\n" description); diff --git a/pkgs/desktops/gnome/extensions/default.nix b/pkgs/desktops/gnome/extensions/default.nix index f98e2fb4e67a..2e5e2ade43e2 100644 --- a/pkgs/desktops/gnome/extensions/default.nix +++ b/pkgs/desktops/gnome/extensions/default.nix @@ -60,17 +60,24 @@ in rec { gnome38Extensions = mapUuidNames (produceExtensionsList "38"); gnome40Extensions = mapUuidNames (produceExtensionsList "40"); - gnomeExtensions = lib.recurseIntoAttrs ( - (mapReadableNames - (lib.attrValues (gnome40Extensions // (callPackages ./manuallyPackaged.nix {}))) - ) - // lib.optionalAttrs (config.allowAliases or true) { + gnomeExtensions = lib.trivial.pipe gnome40Extensions [ + # Apply some custom patches for automatically packaged extensions + (callPackage ./extensionPatches.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 or true) { unite-shell = gnomeExtensions.unite; # added 2021-01-19 arc-menu = gnomeExtensions.arcmenu; # added 2021-02-14 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."; - } - ); + }) + # Make the set "public" + lib.recurseIntoAttrs + ]; } diff --git a/pkgs/desktops/gnome/extensions/extensionPatches.nix b/pkgs/desktops/gnome/extensions/extensionPatches.nix new file mode 100644 index 000000000000..21c75ebf1966 --- /dev/null +++ b/pkgs/desktops/gnome/extensions/extensionPatches.nix @@ -0,0 +1,14 @@ +{ + lib, + ddcutil, + gjs, +}: +# A set of overrides for automatically packaged extensions that require some small fixes. +# The input must be an attribute set with the extensions' UUIDs as keys and the extension +# derivations as values. Output is the same, but with patches applied. +# +# Note that all source patches refer to the built extension as published on extensions.gnome.org, and not +# the upstream repository's sources. +super: super // { + +}