1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-22 21:50:55 +00:00

oh-my-zsh: Update script

This commit is contained in:
Tim Steinbach 2020-11-04 18:12:23 -05:00
parent ac9ba67ec5
commit 9907a2d48b
No known key found for this signature in database
GPG key ID: FD36A5EAAC49035A
2 changed files with 37 additions and 21 deletions

View file

@ -1,7 +1,8 @@
# This script was inspired by the ArchLinux User Repository package:
#
# https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=oh-my-zsh-git
{ stdenv, fetchFromGitHub }:
{ stdenv, fetchFromGitHub, nixosTests, writeScript, common-updater-scripts, git
, nix, nixfmt, jq, coreutils, gnused, curl, cacert }:
stdenv.mkDerivation rec {
version = "2020-10-29";
@ -12,7 +13,7 @@ stdenv.mkDerivation rec {
inherit rev;
owner = "ohmyzsh";
repo = "ohmyzsh";
sha256 = "0021rayw5wiwgjfwy7d6g577xidws58vk7y9xxhidnmk9sr4vri7";
sha256 = "J+ZNsk6z2hZh78mfuVHRvMV+TnmmHc+dfDzywr3KQQA=";
};
installPhase = ''
@ -65,6 +66,40 @@ stdenv.mkDerivation rec {
EOF
'';
passthru = {
updateScript = writeScript "update.sh" ''
#!${stdenv.shell}
set -o errexit
PATH=${
stdenv.lib.makeBinPath [
common-updater-scripts
curl
cacert
git
nixfmt
nix
jq
coreutils
gnused
]
}
oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion oh-my-zsh" | tr -d '"')"
latestSha="$(curl -L -s https://api.github.com/repos/ohmyzsh/ohmyzsh/commits\?sha\=master\&since\=$oldVersion | jq -r '.[0].sha')"
if [ ! "null" = "$latestSha" ]; then
nixpkgs="$(git rev-parse --show-toplevel)"
default_nix="$nixpkgs/pkgs/shells/zsh/oh-my-zsh/default.nix"
latestDate="$(curl -L -s https://api.github.com/repos/ohmyzsh/ohmyzsh/commits/$latestSha | jq '.commit.author.date' | sed 's|"\(.*\)T.*|\1|g')"
update-source-version oh-my-zsh "$latestSha" --version-key=rev
update-source-version oh-my-zsh "$latestDate" --ignore-same-hash
nixfmt "$default_nix"
else
echo "${pname} is already up-to-date"
fi
'';
};
meta = with stdenv.lib; {
description = "A framework for managing your zsh configuration";
longDescription = ''

View file

@ -1,19 +0,0 @@
#!/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 ./. {}; lib.getVersion oh-my-zsh" | tr -d '"')"
latestSha="$(curl -L -s https://api.github.com/repos/ohmyzsh/ohmyzsh/commits\?sha\=master\&since\=${oldVersion} | jq -r '.[0].sha')"
if [ ! "null" = "${latestSha}" ]; then
latestDate="$(curl -L -s https://api.github.com/repos/ohmyzsh/ohmyzsh/commits/${latestSha} | jq '.commit.author.date' | sed 's|"\(.*\)T.*|\1|g')"
update-source-version oh-my-zsh "${latestSha}" --version-key=rev
update-source-version oh-my-zsh "${latestDate}" --ignore-same-hash
nixpkgs="$(git rev-parse --show-toplevel)"
default_nix="$nixpkgs/pkgs/shells/zsh/oh-my-zsh/default.nix"
git add "${default_nix}"
git commit -m "oh-my-zsh: ${oldVersion} -> ${latestDate}"
else
echo "oh-my-zsh is already up-to-date"
fi