From 30ec84fba39777e7e0af7352d89ba1271e5cf45e Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Fri, 18 Feb 2022 07:58:54 +0100 Subject: [PATCH 1/4] unstableGitUpdater: Fix support for fetchFromGit{Hub,Lab} MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When `fetchFromGitHub` uses `fetchzip` instead of `fetchgit` internally, which is the most common use case, there is no `src.url` attribute so the update will fail. Let’s fix that by falling back to `src.meta.homepage`, which these fetchers set to the repository URL. --- pkgs/common-updater/unstable-updater.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/common-updater/unstable-updater.nix b/pkgs/common-updater/unstable-updater.nix index 01f8ae2533e6..ded31e1ddb9c 100644 --- a/pkgs/common-updater/unstable-updater.nix +++ b/pkgs/common-updater/unstable-updater.nix @@ -21,7 +21,7 @@ let # By default we set url to src.url if [[ -z "$url" ]]; then url="$(${nix}/bin/nix-instantiate $systemArg --eval -E \ - "with import ./. {}; $UPDATE_NIX_ATTR_PATH.src.url" \ + "with import ./. {}; $UPDATE_NIX_ATTR_PATH.src.url or $UPDATE_NIX_ATTR_PATH.src.meta.homepage" \ | tr -d '"')" fi From 3985dde04ee0eb5d6a2e6778b1ade9aaacbe9d45 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Fri, 18 Feb 2022 08:12:44 +0100 Subject: [PATCH 2/4] unstableGitUpdater: Use single derivation for all branches This will reduce the number of build when updating a large number of packages at the same time (e.g. when updating all packages of a maintainer). --- pkgs/common-updater/unstable-updater.nix | 42 +++++++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/pkgs/common-updater/unstable-updater.nix b/pkgs/common-updater/unstable-updater.nix index ded31e1ddb9c..966834093711 100644 --- a/pkgs/common-updater/unstable-updater.nix +++ b/pkgs/common-updater/unstable-updater.nix @@ -16,7 +16,25 @@ let updateScript = writeShellScript "unstable-update-script.sh" '' set -ex - url="$1" + url="" + branch="" + + while (( $# > 0 )); do + flag="$1" + shift 1 + case "$flag" in + --url=*) + url="''${flag#*=}" + ;; + --branch=*) + branch="''${flag#*=}" + ;; + *) + echo "$0: unknown option ‘''${flag}’" + exit 1 + ;; + esac + done # By default we set url to src.url if [[ -z "$url" ]]; then @@ -27,9 +45,18 @@ let # Get info about HEAD from a shallow git clone tmpdir="$(${coreutils}/bin/mktemp -d)" - ${git}/bin/git clone --bare --depth=1 \ - ${lib.optionalString (branch != null) "--branch ${branch}"} \ - "$url" "$tmpdir" + + cloneArgs=( + --bare + --depth=1 + ) + + if [[ -n "$branch" ]]; then + cloneArgs+=(--branch="$branch") + fi + + ${git}/bin/git clone "''${cloneArgs[@]}" "$url" "$tmpdir" + pushd "$tmpdir" commit_date="$(${git}/bin/git show -s --pretty='format:%cs')" commit_sha="$(${git}/bin/git show -s --pretty='format:%H')" @@ -43,5 +70,10 @@ let --rev="$commit_sha" ''; -in [ updateScript url ] +in [ + updateScript + "--url=${builtins.toString url}" +] ++ lib.optionals (branch != null) [ + "--branch=${branch}" +] From 97276fe65022496b1b925616064546a07eba3ac2 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Fri, 18 Feb 2022 08:19:31 +0100 Subject: [PATCH 3/4] unstableGitUpdater: Allow using stable versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is important to keep the version as parsed by `builtins.parseDrvName` monotonic for packages that often switch between stable and unstable versions, for nix-env to be able to update them reliably. Let’s optionally use the version format described by RFC 107: https://github.com/NixOS/rfcs/pull/107 The downside is that it requires fetching more commits to be able to determine the latest tag. --- pkgs/common-updater/unstable-updater.nix | 39 ++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/pkgs/common-updater/unstable-updater.nix b/pkgs/common-updater/unstable-updater.nix index 966834093711..14f25a91601c 100644 --- a/pkgs/common-updater/unstable-updater.nix +++ b/pkgs/common-updater/unstable-updater.nix @@ -10,6 +10,8 @@ # commit. { url ? null # The git url, if empty it will be set to src.url , branch ? null +, stableVersion ? false # Use version format according to RFC 107 (i.e. LAST_TAG+date=YYYY-MM-DD) +, tagPrefix ? "" # strip this prefix from a tag name when using stable version }: let @@ -18,6 +20,8 @@ let url="" branch="" + use_stable_version="" + tag_prefix="" while (( $# > 0 )); do flag="$1" @@ -29,6 +33,12 @@ let --branch=*) branch="''${flag#*=}" ;; + --use-stable-version) + use_stable_version=1 + ;; + --tag-prefix=*) + tag_prefix="''${flag#*=}" + ;; *) echo "$0: unknown option ‘''${flag}’" exit 1 @@ -60,13 +70,34 @@ let pushd "$tmpdir" commit_date="$(${git}/bin/git show -s --pretty='format:%cs')" commit_sha="$(${git}/bin/git show -s --pretty='format:%H')" + if [[ -z "$use_stable_version" ]]; then + new_version="unstable-$commit_date" + else + depth=100 + while (( $depth < 10000 )); do + last_tag="$(${git}/bin/git describe --tags --abbrev=0 2> /dev/null || true)" + if [[ -n "$last_tag" ]]; then + break + fi + ${git}/bin/git fetch --depth="$depth" --tags + depth=$(( $depth * 2 )) + done + if [[ -z "$last_tag" ]]; then + echo "Cound not found a tag within last 10000 commits" > /dev/stderr + exit 1 + fi + if [[ -n "$tag_prefix" ]]; then + last_tag="''${last_tag#$tag_prefix}" + fi + new_version="$last_tag+date=$commit_date" + fi popd - ${coreutils}/bin/rm -rf "$tmpdir" + # ${coreutils}/bin/rm -rf "$tmpdir" # update the nix expression ${common-updater-scripts}/bin/update-source-version \ "$UPDATE_NIX_ATTR_PATH" \ - "unstable-$commit_date" \ + "$new_version" \ --rev="$commit_sha" ''; @@ -75,5 +106,7 @@ in [ "--url=${builtins.toString url}" ] ++ lib.optionals (branch != null) [ "--branch=${branch}" +] ++ lib.optionals stableVersion [ + "--use-stable-version" + "--tag-prefix=${tagPrefix}" ] - From 967a4c22db36bfa21ffec477bcf1fa5046099e2c Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Fri, 18 Feb 2022 07:42:11 +0100 Subject: [PATCH 4/4] gnomeExtensions.dash-to-dock: Build from source again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The stable version has several usability bugs (e.g. https://github.com/micheleg/dash-to-dock/issues/1629) but patches do not apply cleanly to the zips from the extension portal. Let’s switch back to building from source to make it easier to update the extension. This reverts commit 2bb795bab24f00d60b164ab40b504201a0cefa20, adds an update script and updates to latest git revision. --- .../gnome/extensions/dash-to-dock/default.nix | 48 +++++++++++++++++++ .../gnome/extensions/extensionOverrides.nix | 4 -- .../gnome/extensions/manuallyPackaged.nix | 1 + 3 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 pkgs/desktops/gnome/extensions/dash-to-dock/default.nix diff --git a/pkgs/desktops/gnome/extensions/dash-to-dock/default.nix b/pkgs/desktops/gnome/extensions/dash-to-dock/default.nix new file mode 100644 index 000000000000..c78a59af5237 --- /dev/null +++ b/pkgs/desktops/gnome/extensions/dash-to-dock/default.nix @@ -0,0 +1,48 @@ +{ stdenv +, lib +, fetchFromGitHub +, glib +, gettext +, sassc +, unstableGitUpdater +}: + +stdenv.mkDerivation rec { + pname = "gnome-shell-extension-dash-to-dock"; + version = "71+date=2022-01-24"; + + # Temporarily switched to commit hash because stable version is buggy. + src = fetchFromGitHub { + owner = "micheleg"; + repo = "dash-to-dock"; + rev = "53114b4e000482a753e8b42dfa10d6057c08d1c6"; + sha256 = "Gv78I/dxhc6FpjZWk10uHBfD24tHE4KdkpaAo8UZpwU="; + }; + + nativeBuildInputs = [ + glib + gettext + sassc + ]; + + makeFlags = [ + "INSTALLBASE=${placeholder "out"}/share/gnome-shell/extensions" + ]; + + passthru = { + extensionUuid = "dash-to-dock@micxgx.gmail.com"; + extensionPortalSlug = "dash-to-dock"; + + updateScript = unstableGitUpdater { + stableVersion = true; + tagPrefix = "extensions.gnome.org-v"; + }; + }; + + meta = with lib; { + description = "A dock for the Gnome Shell"; + homepage = "https://micheleg.github.io/dash-to-dock/"; + license = licenses.gpl2Plus; + maintainers = with maintainers; [ eperuffo jtojnar rhoriguchi ]; + }; +} diff --git a/pkgs/desktops/gnome/extensions/extensionOverrides.nix b/pkgs/desktops/gnome/extensions/extensionOverrides.nix index da95f3244095..bc659b9a4438 100644 --- a/pkgs/desktops/gnome/extensions/extensionOverrides.nix +++ b/pkgs/desktops/gnome/extensions/extensionOverrides.nix @@ -28,10 +28,6 @@ super: lib.trivial.pipe super [ meta.maintainers = with lib.maintainers; [ eperuffo ]; })) - (patchExtension "dash-to-dock@micxgx.gmail.com" (old: { - meta.maintainers = with lib.maintainers; [ eperuffo jtojnar rhoriguchi ]; - })) - (patchExtension "ddterm@amezin.github.com" (old: { # Requires gjs, zenity & vte via the typelib nativeBuildInputs = [ gobject-introspection wrapGAppsHook ]; diff --git a/pkgs/desktops/gnome/extensions/manuallyPackaged.nix b/pkgs/desktops/gnome/extensions/manuallyPackaged.nix index 28d0f32777a8..1ed840670643 100644 --- a/pkgs/desktops/gnome/extensions/manuallyPackaged.nix +++ b/pkgs/desktops/gnome/extensions/manuallyPackaged.nix @@ -2,6 +2,7 @@ { "arcmenu@arcmenu.com" = callPackage ./arcmenu { }; "clock-override@gnomeshell.kryogenix.org" = callPackage ./clock-override { }; + "dash-to-dock@micxgx.gmail.com" = callPackage ./dash-to-dock { }; "drop-down-terminal@gs-extensions.zzrough.org" = callPackage ./drop-down-terminal { }; "EasyScreenCast@iacopodeenosee.gmail.com" = callPackage ./EasyScreenCast { }; "emoji-selector@maestroschan.fr" = callPackage ./emoji-selector { };