From df93edee15b59d965d3f3f7c136d2f45e3c7828d Mon Sep 17 00:00:00 2001 From: Tim Steinbach Date: Fri, 2 Aug 2019 08:52:06 -0400 Subject: [PATCH] slack: Add update script --- .../instant-messengers/slack/dark-theme.nix | 17 +++++++---------- .../instant-messengers/slack/update.sh | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 10 deletions(-) create mode 100755 pkgs/applications/networking/instant-messengers/slack/update.sh diff --git a/pkgs/applications/networking/instant-messengers/slack/dark-theme.nix b/pkgs/applications/networking/instant-messengers/slack/dark-theme.nix index d815f0aff2dd..8fb92766efa6 100644 --- a/pkgs/applications/networking/instant-messengers/slack/dark-theme.nix +++ b/pkgs/applications/networking/instant-messengers/slack/dark-theme.nix @@ -1,22 +1,19 @@ -{ stdenv, fetchurl }: +{ stdenv, fetchgit }: -let +stdenv.mkDerivation rec { rev = "e2a6a9cd9da70175881ab991220c86aa87179509"; - sha256 = "1gw0kpszgflk3vqjlm5igd2rznh36mb2j1iqrcqi6pzxlpccv1lg"; version = "2019-07-25"; -in stdenv.mkDerivation { - inherit version; + name = "slack-theme-black-${version}"; - name = "slack-theme-black"; - src = fetchurl { - url = "https://raw.githubusercontent.com/laCour/slack-night-mode/${rev}/css/raw/black.css"; - inherit sha256; + src = fetchgit { inherit rev; + url = "https://github.com/laCour/slack-night-mode"; + sha256 = "1jwxy63qzgvr83idsgcg7yhm9kn0ybfji1m964c5c6ypzcm7j10v"; }; dontUnpack = true; buildCommand = '' mkdir $out - cp $src $out/theme.css + cp $src/css/raw/black.css $out/theme.css ''; } diff --git a/pkgs/applications/networking/instant-messengers/slack/update.sh b/pkgs/applications/networking/instant-messengers/slack/update.sh new file mode 100755 index 000000000000..e5f793883538 --- /dev/null +++ b/pkgs/applications/networking/instant-messengers/slack/update.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl common-updater-scripts jq + +set -eu -o pipefail + +oldVersion="$(nix-instantiate --eval -E "with import ./. {}; slack-theme-black.version or (builtins.parseDrvName slack-theme-black.name).version" | tr -d '"')" +latestSha="$(curl -L -s https://api.github.com/repos/laCour/slack-night-mode/commits\?sha\=master\&since\=${oldVersion} | jq -r '.[0].sha')" + +if [ ! "null" = "${latestSha}" ]; then + latestDate="$(curl -L -s https://api.github.com/repos/laCour/slack-night-mode/commits/${latestSha} | jq '.commit.author.date' | sed 's|"\(.*\)T.*|\1|g')" + update-source-version slack-theme-black "${latestSha}" --version-key=rev + update-source-version slack-theme-black "${latestDate}" --ignore-same-hash + nixpkgs="$(git rev-parse --show-toplevel)" + default_nix="$nixpkgs/pkgs/applications/networking/instant-messengers/slack/dark-theme.nix" + git add "${default_nix}" + git commit -m "slack-theme-black: ${oldVersion} -> ${latestDate}" +else + echo "slack-theme-black is already up-to-date" +fi