Skip to content

Commit

Permalink
Add script buildkit-update.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
totten committed Aug 22, 2023
1 parent 36ab9bc commit 1473926
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 9 deletions.
35 changes: 35 additions & 0 deletions nix/buildkit-update.sh
Original file line number Diff line number Diff line change
@@ -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 <nixpkgs> {} }:"
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
}
12 changes: 12 additions & 0 deletions nix/buildkit.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{ pkgs ? import <nixpkgs> {} }:

## 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")
10 changes: 1 addition & 9 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1473926

Please sign in to comment.