2021-05-10 23:01:02 +02:00
|
|
|
{ pkgs, lib, stdenv, fetchzip }:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
buildGnomeExtension = {
|
|
|
|
# Every gnome extension has a UUID. It's the name of the extension folder once unpacked
|
|
|
|
# and can always be found in the metadata.json of every extension.
|
|
|
|
uuid,
|
|
|
|
name,
|
|
|
|
pname,
|
|
|
|
description,
|
|
|
|
# extensions.gnome.org extension URL
|
|
|
|
link,
|
|
|
|
# Extension version numbers are integers
|
|
|
|
version,
|
|
|
|
sha256,
|
|
|
|
# Hex-encoded string of JSON bytes
|
|
|
|
metadata,
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
2021-05-24 22:01:59 +02:00
|
|
|
pname = "gnome-shell-extension-${pname}";
|
2021-05-10 23:01:02 +02:00
|
|
|
version = builtins.toString version;
|
|
|
|
src = fetchzip {
|
|
|
|
url = "https://extensions.gnome.org/extension-data/${
|
|
|
|
builtins.replaceStrings [ "@" ] [ "" ] uuid
|
|
|
|
}.v${builtins.toString version}.shell-extension.zip";
|
|
|
|
inherit sha256;
|
|
|
|
stripRoot = false;
|
|
|
|
# The download URL may change content over time. This is because the
|
|
|
|
# metadata.json is automatically generated, and parts of it can be changed
|
|
|
|
# without making a new release. We simply substitute the possibly changed fields
|
|
|
|
# with their content from when we last updated, and thus get a deterministic output
|
|
|
|
# hash.
|
|
|
|
extraPostFetch = ''
|
|
|
|
echo "${metadata}" | base64 --decode > $out/metadata.json
|
|
|
|
'';
|
|
|
|
};
|
2021-09-08 22:49:05 +02:00
|
|
|
dontBuild = true;
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2021-05-10 23:01:02 +02:00
|
|
|
mkdir -p $out/share/gnome-shell/extensions/
|
2021-09-08 22:49:05 +02:00
|
|
|
cp -r -T . $out/share/gnome-shell/extensions/${uuid}
|
|
|
|
runHook postInstall
|
2021-05-10 23:01:02 +02:00
|
|
|
'';
|
|
|
|
meta = {
|
|
|
|
description = builtins.head (lib.splitString "\n" description);
|
|
|
|
longDescription = description;
|
|
|
|
homepage = link;
|
|
|
|
license = lib.licenses.gpl2Plus; # https://wiki.gnome.org/Projects/GnomeShell/Extensions/Review#Licensing
|
|
|
|
maintainers = with lib.maintainers; [ piegames ];
|
|
|
|
};
|
2021-05-25 02:34:21 +02:00
|
|
|
passthru = {
|
|
|
|
extensionPortalSlug = pname;
|
|
|
|
# Store the extension's UUID, because we might need it at some places
|
|
|
|
extensionUuid = uuid;
|
|
|
|
};
|
2021-05-10 23:01:02 +02:00
|
|
|
};
|
|
|
|
in
|
|
|
|
lib.makeOverridable buildGnomeExtension
|