From d8098cb1b65c162cf954567343d4c0440290852b Mon Sep 17 00:00:00 2001 From: Madoura Date: Thu, 19 Oct 2023 01:03:10 -0500 Subject: tokyo-night-gtk: unstable-2023-01-17 -> unstable-2023-05-30 --- pkgs/data/themes/tokyo-night-gtk/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/data/themes/tokyo-night-gtk/default.nix b/pkgs/data/themes/tokyo-night-gtk/default.nix index a117562174e5..3fb7fddd11f9 100644 --- a/pkgs/data/themes/tokyo-night-gtk/default.nix +++ b/pkgs/data/themes/tokyo-night-gtk/default.nix @@ -6,13 +6,13 @@ stdenvNoCC.mkDerivation { pname = "tokyo-night-gtk"; - version = "2023.01.17"; + version = "unstable-2023-05-30"; src = fetchFromGitHub { owner = "Fausto-Korpsvart"; repo = "Tokyo-Night-GTK-Theme"; - rev = "f7ae3421ac0d415ca57fb6224e093e12b8a980bb"; - sha256 = "sha256-90V55pRfgiaP1huhD+3456ziJ2EU24iNQHt5Ro+g+M0="; + rev = "e9790345a6231cd6001f1356d578883fac52233a"; + hash = "sha256-Q9UnvmX+GpvqSmTwdjU4hsEsYhA887wPqs5pyqbIhmc="; }; propagatedUserEnvPkgs = [ -- cgit 1.4.1 From 70bae1d428fa40e42fd4d8eb02be2390291186b1 Mon Sep 17 00:00:00 2001 From: Madoura Date: Thu, 26 Oct 2023 06:00:10 -0500 Subject: tokyo-night-gtk: refactor and default to tokyo-night-gtk-variants.full This allows us to specify which icons/themes we want instead of keeping 100k+ files --- pkgs/data/themes/tokyo-night-gtk/default.nix | 56 +++++++++---------- pkgs/data/themes/tokyo-night-gtk/generic.nix | 77 ++++++++++++++++++++++++++ pkgs/data/themes/tokyo-night-gtk/variants.json | 18 ++++++ pkgs/top-level/all-packages.nix | 4 +- 4 files changed, 126 insertions(+), 29 deletions(-) create mode 100644 pkgs/data/themes/tokyo-night-gtk/generic.nix create mode 100644 pkgs/data/themes/tokyo-night-gtk/variants.json diff --git a/pkgs/data/themes/tokyo-night-gtk/default.nix b/pkgs/data/themes/tokyo-night-gtk/default.nix index 3fb7fddd11f9..dc3273e695b1 100644 --- a/pkgs/data/themes/tokyo-night-gtk/default.nix +++ b/pkgs/data/themes/tokyo-night-gtk/default.nix @@ -1,38 +1,38 @@ { lib -, stdenvNoCC -, fetchFromGitHub +, callPackage +, runCommand , gtk-engine-murrine +, gnome-themes-extra }: -stdenvNoCC.mkDerivation { - pname = "tokyo-night-gtk"; - version = "unstable-2023-05-30"; +let + prefix = "tokyo-night-gtk"; - src = fetchFromGitHub { - owner = "Fausto-Korpsvart"; - repo = "Tokyo-Night-GTK-Theme"; - rev = "e9790345a6231cd6001f1356d578883fac52233a"; - hash = "sha256-Q9UnvmX+GpvqSmTwdjU4hsEsYhA887wPqs5pyqbIhmc="; - }; + packages = lib.mapAttrs' (type: content: { + name = type; - propagatedUserEnvPkgs = [ - gtk-engine-murrine - ]; + value = lib.mapAttrs' (variantName: variant: { + name = variantName; + value = callPackage ./generic.nix { inherit prefix type variantName variant; }; + }) content; + }) (lib.importJSON ./variants.json); +in packages // { + # Not using `symlinkJoin` because it's massively inefficient in this case + full = runCommand "${prefix}_full" { + preferLocalBuild = true; - dontBuild = true; + propagatedUserEnvPkgs = [ + gtk-engine-murrine + gnome-themes-extra + ]; + } '' + mkdir -p $out/share/{icons,themes,${prefix}} - installPhase = '' - runHook preInstall - mkdir -p $out/share/themes - cp -a themes/* $out/share/themes - runHook postInstall + ${lib.concatStrings (lib.forEach (lib.attrValues (lib.attrsets.mergeAttrsList (lib.attrValues packages))) (variant: + '' + ln -s ${variant}/share/${variant.ptype}/Tokyonight-${variant.pvariant} $out/share/${variant.ptype}/Tokyonight-${variant.pvariant} + ln -s ${variant}/share/${prefix}/LICENSE $out/share/${prefix}/LICENSE 2>/dev/null || true + '' + ))} ''; - - meta = with lib; { - description = "A GTK theme based on the Tokyo Night colour palette."; - homepage = "www.pling.com/p/1681315/"; - license = licenses.gpl3Only; - platforms = platforms.unix; - maintainers = with lib.maintainers; [ garaiza-93 ]; - }; } diff --git a/pkgs/data/themes/tokyo-night-gtk/generic.nix b/pkgs/data/themes/tokyo-night-gtk/generic.nix new file mode 100644 index 000000000000..35bf498666da --- /dev/null +++ b/pkgs/data/themes/tokyo-night-gtk/generic.nix @@ -0,0 +1,77 @@ +{ lib +, stdenvNoCC +, fetchFromGitHub +, writeScript +, gtk-engine-murrine +, gnome-themes-extra +, prefix ? "" +, type ? "" +, variantName ? "" +, variant ? "" +}: + +stdenvNoCC.mkDerivation (finalAttrs: { + pname = "${prefix}_${type}-${variantName}"; + version = "unstable-2023-05-30"; + + src = fetchFromGitHub { + owner = "Fausto-Korpsvart"; + repo = "Tokyo-Night-GTK-Theme"; + rev = "e9790345a6231cd6001f1356d578883fac52233a"; + hash = "sha256-Q9UnvmX+GpvqSmTwdjU4hsEsYhA887wPqs5pyqbIhmc="; + }; + + propagatedUserEnvPkgs = [ + gtk-engine-murrine + gnome-themes-extra + ]; + + dontPatch = true; + dontConfigure = true; + dontBuild = true; + dontFixup = true; + + installPhase = '' + runHook preInstall + + mkdir -p $out/share/{${type},${prefix}} + cp -a ${type}/Tokyonight-${variant} $out/share/${type} + cp -a LICENSE $out/share/${prefix} + + runHook postInstall + ''; + + passthru = { + updateScript = writeScript "update.sh" '' + #!/usr/bin/env nix-shell + #!nix-shell -i bash -p curl common-updater-scripts tree jq + res="$(curl ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \ + -sL "https://api.github.com/repos/${finalAttrs.src.owner}/${finalAttrs.src.repo}/commits/HEAD")" + + rev="$(echo $res | jq '.sha' --raw-output)" + version="unstable-$(echo $res | jq '.commit | .author | .date' --raw-output | sed 's/T.*$//')" + update-source-version ${prefix}-variants.${type}.${variantName} "$version" "$rev" --ignore-same-hash + + commonjq1='.[] .contents .[] | {(.name): .name} | walk(if type=="object" then with_entries(.key|=ascii_downcase) else . end)' + commonjq2='reduce inputs as $in (.; . + $in)' + commontree="-dJ -L 1 --noreport ${finalAttrs.src}" + + echo $(tree $commontree/icons | jq "$commonjq1" | jq "$commonjq2" | jq '{icons: .}') \ + $(tree $commontree/themes | jq "$commonjq1" | jq "$commonjq2" | jq '{themes: .}') | \ + jq 'reduce inputs as $in (.; . + $in)' | sed "s/[tT]okyonight-//g" > \ + "$(git rev-parse --show-toplevel)/pkgs/data/themes/${prefix}/variants.json" + ''; + + # For "full" in default.nix + ptype = type; + pvariant = variant; + }; + + meta = with lib; { + description = "A GTK theme based on the Tokyo Night colour palette"; + homepage = "https://www.pling.com/p/1681315"; + license = licenses.gpl3Only; + platforms = platforms.unix; + maintainers = with maintainers; [ garaiza-93 Madouura ]; + }; +}) diff --git a/pkgs/data/themes/tokyo-night-gtk/variants.json b/pkgs/data/themes/tokyo-night-gtk/variants.json new file mode 100644 index 000000000000..6489d9c649de --- /dev/null +++ b/pkgs/data/themes/tokyo-night-gtk/variants.json @@ -0,0 +1,18 @@ +{ + "icons": { + "dark": "Dark", + "dark-cyan": "Dark-Cyan", + "light": "Light", + "moon": "Moon" + }, + "themes": { + "dark-b": "Dark-B", + "dark-bl": "Dark-BL", + "dark-b-lb": "Dark-B-LB", + "dark-bl-lb": "Dark-BL-LB", + "storm-b": "Storm-B", + "storm-bl": "Storm-BL", + "storm-b-lb": "Storm-B-LB", + "storm-bl-lb": "Storm-BL-LB" + } +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index eacb266e2ff7..505760c9593e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -35884,7 +35884,9 @@ with pkgs; tofi = callPackage ../applications/misc/tofi { }; - tokyo-night-gtk = callPackage ../data/themes/tokyo-night-gtk { }; + tokyo-night-gtk = tokyo-night-gtk-variants.full; + + tokyo-night-gtk-variants = recurseIntoAttrs (callPackage ../data/themes/tokyo-night-gtk { }); topydo = callPackage ../applications/misc/topydo { }; -- cgit 1.4.1