···11+#!/usr/bin/env nix-shell
22+#!nix-shell -i bash -p cabal2nix curl jq
33+#
44+# This script will update the dconf2nix derivation to the latest version using
55+# cabal2nix.
66+77+set -eo pipefail
88+99+# This is the directory of this update.sh script.
1010+script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
1111+1212+# dconf2nix derivation created with cabal2nix.
1313+dconf2nix_derivation_file="${script_dir}/dconf2nix.nix"
1414+1515+# This is the current revision of dconf2nix in Nixpkgs.
1616+old_version="$(sed -En 's/.*\bversion = "(.*?)".*/\1/p' "$dconf2nix_derivation_file")"
1717+1818+# This is the latest release version of dconf2nix on GitHub.
1919+new_version=$(curl --silent "https://api.github.com/repos/gvolpe/dconf2nix/releases" | jq '.[0].tag_name' --raw-output)
2020+2121+echo "Updating dconf2nix from old version $old_version to new version $new_version."
2222+echo "Running cabal2nix and outputting to ${dconf2nix_derivation_file}..."
2323+2424+cabal2nix --revision "$new_version" "https://github.com/gvolpe/dconf2nix.git" > "$dconf2nix_derivation_file"
2525+2626+echo "Finished."