slack: Add update script

This commit is contained in:
Tim Steinbach 2019-08-02 08:52:06 -04:00
parent a33198f74b
commit df93edee15
No known key found for this signature in database
GPG key ID: 6C654787275A64F1
2 changed files with 26 additions and 10 deletions

View file

@ -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
'';
}

View file

@ -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