From bc1f025afb28de72e9a8363d7553bafcffc086c8 Mon Sep 17 00:00:00 2001 From: piegames Date: Mon, 22 Nov 2021 01:51:52 +0100 Subject: [PATCH] gnomeExtensions: improve override mechanism The reduced reduncancy should help us avoid making some copy-paste errors, as happened previously. Also, increased ergonomics. --- .../gnome/extensions/extensionOverrides.nix | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/pkgs/desktops/gnome/extensions/extensionOverrides.nix b/pkgs/desktops/gnome/extensions/extensionOverrides.nix index e8f9fb9cfb33..f20c63d08016 100644 --- a/pkgs/desktops/gnome/extensions/extensionOverrides.nix +++ b/pkgs/desktops/gnome/extensions/extensionOverrides.nix @@ -3,31 +3,36 @@ , gjs , xprop }: +let + # Helper method to reduce redundancy + patchExtension = name: override: super: (super // { + ${name} = super.${name}.overrideAttrs override; + }); +in # 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 // { - - "caffeine@patapon.info" = super."caffeine@patapon.info".overrideAttrs (old: { +super: lib.trivial.pipe super [ + (patchExtension "caffeine@patapon.info" (old: { meta.maintainers = with lib.maintainers; [ eperuffo ]; - }); + })) - "dash-to-dock@micxgx.gmail.com" = super."dash-to-dock@micxgx.gmail.com".overrideAttrs (old: { + (patchExtension "dash-to-dock@micxgx.gmail.com" (old: { meta.maintainers = with lib.maintainers; [ eperuffo jtojnar rhoriguchi ]; - }); + })) - "display-brightness-ddcutil@themightydeity.github.com" = super."display-brightness-ddcutil@themightydeity.github.com".overrideAttrs (old: { + (patchExtension "display-brightness-ddcutil@themightydeity.github.com" (old: { # Has a hard-coded path to a run-time dependency # https://github.com/NixOS/nixpkgs/issues/136111 postPatch = '' substituteInPlace "extension.js" --replace "/usr/bin/ddcutil" "${ddcutil}/bin/ddcutil" ''; - }); + })) - "gnome-shell-screenshot@ttll.de" = super."gnome-shell-screenshot@ttll.de".overrideAttrs (old: { + (patchExtension "gnome-shell-screenshot@ttll.de" (old: { # Requires gjs # https://github.com/NixOS/nixpkgs/issues/136112 postPatch = '' @@ -35,12 +40,11 @@ super: super // { substituteInPlace $file --replace "gjs" "${gjs}/bin/gjs" done ''; - }); + })) - "unite@hardpixel.eu" = super."unite@hardpixel.eu".overrideAttrs (old: { + (patchExtension "unite@hardpixel.eu" (old: { buildInputs = [ xprop ]; meta.maintainers = with lib.maintainers; [ rhoriguchi ]; - }); - -} + })) +]