Merge pull request #20 from matthewbauer/patch-2

Lookup attribute using nix-env
This commit is contained in:
Ryan Mulligan 2018-03-17 07:37:07 -07:00 committed by GitHub
commit 974e23acec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

13
up.sh
View File

@ -48,7 +48,10 @@ git reset --hard
git checkout master
git reset --hard upstream/master
DERIVATION_FILE=$(EDITOR=echo nix edit $1 -f .) || error_exit "Couldn't find derivation file."
# This is extremely slow but will give us better results
ATTR_PATH=$(nix-env -qa $PACKAGE_NAME-$OLD_VERSION -f . --attr-path | head -n1 | cut -d' ' -f1)
DERIVATION_FILE=$(EDITOR=echo nix edit $ATTR_PATH -f .) || error_exit "Couldn't find derivation file."
function error_cleanup {
cleanup
@ -91,11 +94,11 @@ grep "$OLD_VERSION" "$DERIVATION_FILE" || error_exit "Old version not present in
git checkout `git merge-base upstream/master upstream/staging`
git checkout -B "$BRANCH_NAME"
OLD_HASH=$(nix eval -f . --raw "pkgs.${PACKAGE_NAME}.src.drvAttrs.outputHash" || error_exit "Couldn't find old output hash at PACKAGE_NAME.src.drvAttrs.outputHash.")
OLD_HASH=$(nix eval -f . --raw "pkgs.$ATTR_PATH.src.drvAttrs.outputHash" || error_exit "Couldn't find old output hash at ATTR_PATH.src.drvAttrs.outputHash.")
sed -i "s/${OLD_VERSION//\./\\.}/$NEW_VERSION/g" "$DERIVATION_FILE" || error_exit "Could not replace OLD_VERSION with NEW_VERSION."
NEW_HASH=$(nix-prefetch-url -A "$PACKAGE_NAME.src" || error_exit "Could not prefetch new version URL.")
NEW_HASH=$(nix-prefetch-url -A "$ATTR_PATH.src" || error_exit "Could not prefetch new version URL.")
if [ "$OLD_HASH" = "$NEW_HASH" ]
then
@ -106,7 +109,7 @@ sed -i "s/$OLD_HASH/$NEW_HASH/g" "$DERIVATION_FILE" || error_exit "Could not rep
rm -f result*
nix build -f . $PACKAGE_NAME || error_exit "nix build failed."
nix build -f . $ATTR_PATH || error_exit "nix build failed."
RESULT=$(readlink ./result || readlink ./result-bin || error_exit "Couldn't find result link.")
@ -115,7 +118,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
CHECK_RESULT=$($SCRIPT_DIR/check-result.sh $RESULT $NEW_VERSION)
MAINTAINERS=
if nix eval "(let pkgs = import ./. {}; in pkgs.$PACKAGE_NAME.meta.maintainers)" > /dev/null 2>&1
if nix eval "(let pkgs = import ./. {}; in pkgs.$ATTR_PATH.meta.maintainers)" > /dev/null 2>&1
then
maintainers=$(nix eval --raw '(let pkgs = import ./. {}; gh = m : m.github or ""; nonempty = s: s != ""; addat = s: "@"+s; in builtins.concatStringsSep " " (map addat (builtins.filter nonempty (map gh pkgs.'"${PACKAGE_NAME}"'.meta.maintainers))))')
if [ -n "$maintainers" ]