diff --git a/nix/buildkit-update.sh b/nix/buildkit-update.sh new file mode 100755 index 00000000..6b5a43c6 --- /dev/null +++ b/nix/buildkit-update.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +{ # https://stackoverflow.com/a/21100710 + + ## Re-generate the buildkit.nix file - with the current 'master' branch. + + set -e + + if [ ! -f "nix/buildkit.nix" ]; then + echo >&2 "Must run in project root" + exit 1 + fi + + now=$( date -u '+%Y-%m-%d %H:%M %Z' ) + commit=$( git ls-remote https://github.com/civicrm/civicrm-buildkit.git | awk '/refs\/heads\/master$/ { print $1 }' ) + url="https://github.com/civicrm/civicrm-buildkit/archive/${commit}.tar.gz" + hash=$( nix-prefetch-url "$url" --type sha256 --unpack ) + + function render_file() { + echo "{ pkgs ? import {} }:" + echo "" + echo "## Get civicrm-buildkit from github." + echo "## Based on \"master\" branch circa $now" + echo "import (pkgs.fetchzip {" + echo " url = \"$url\";" + echo " sha256 = \"$hash\";" + echo "})" + echo + echo "## Get a local copy of civicrm-buildkit. (Useful for developing patches.)" + echo "# import ((builtins.getEnv \"HOME\") + \"/buildkit/default.nix\")" + echo "# import ((builtins.getEnv \"HOME\") + \"/bknix/default.nix\")" + } + render_file > nix/buildkit.nix + + exit +} diff --git a/nix/buildkit.nix b/nix/buildkit.nix new file mode 100644 index 00000000..e9f3d6f4 --- /dev/null +++ b/nix/buildkit.nix @@ -0,0 +1,12 @@ +{ pkgs ? import {} }: + +## Get civicrm-buildkit from github. +## Based on "master" branch circa 2023-08-22 10:32 UTC +import (pkgs.fetchzip { + url = "https://github.com/civicrm/civicrm-buildkit/archive/04b338a52bbf0bdc21edafe564b875138c1db12c.tar.gz"; + sha256 = "1r6m830lyv6xf0yxz392izhwlnbahhc7s4r71riyqryzkr6psfyd"; +}) + +## Get a local copy of civicrm-buildkit. (Useful for developing patches.) +# import ((builtins.getEnv "HOME") + "/buildkit/default.nix") +# import ((builtins.getEnv "HOME") + "/bknix/default.nix") diff --git a/shell.nix b/shell.nix index d7fa37c3..65068719 100644 --- a/shell.nix +++ b/shell.nix @@ -8,15 +8,7 @@ let - buildkit = import (pkgs.fetchFromGitHub { - owner = "totten"; - repo = "civicrm-buildkit"; - rev = "153371e9bdcb22392b878cca545df0888fb61925"; - sha256 = "sha256-rdwmA4uqIqfqXu2f+ewVH0Gs/BzcB13p8oRbbTdUsAs="; - }); - - ## If you're trying to patch buildkit at the sametime, then use a local copy: - #buildkit = import ((builtins.getEnv "HOME") + "/bknix/default.nix"); + buildkit = (import ./nix/buildkit.nix) { inherit pkgs; }; in