nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 writeShellScript,
4 git,
5 nix,
6 bundler,
7 bundix,
8 coreutils,
9 common-updater-scripts,
10}:
11writeShellScript "update-script" ''
12 set -eu
13 PATH=${
14 lib.makeBinPath [
15 git
16 nix
17 bundler
18 bundix
19 coreutils
20 common-updater-scripts
21 ]
22 }
23 nix() {
24 command nix --extra-experimental-features nix-command "$@"
25 }
26 bundle() {
27 BUNDLE_FORCE_RUBY_PLATFORM=1 command bundle "$@"
28 }
29
30 attrPath=''${UPDATE_NIX_ATTR_PATH:-pghero}
31
32 toplevel=$(git rev-parse --show-toplevel)
33 position=$(nix eval --file "$toplevel" --raw "$attrPath.meta.position")
34 gemdir=$(dirname "$position")
35
36 cd "$gemdir"
37
38 tempdir=$(mktemp -d)
39 cleanup() {
40 rc=$?
41 rm -r -- "$tempdir" || true
42 exit $rc
43 }
44 trap cleanup EXIT
45
46 cp gemset.nix "$tempdir"
47
48 bundle lock --update --lockfile="$tempdir"/Gemfile.lock
49 bundix --lockfile="$tempdir"/Gemfile.lock --gemset="$tempdir"/gemset.nix
50
51 oldVersion=''${UPDATE_NIX_OLD_VERSION-}
52 newVersion=$(nix eval --file "$tempdir"/gemset.nix --raw pghero.version)
53
54 if [ "$oldVersion" = "$newVersion" ]; then
55 exit
56 fi
57
58 cp "$tempdir"/{Gemfile.lock,gemset.nix} .
59
60 cd "$toplevel"
61 update-source-version "$attrPath" "$newVersion" --file="$gemdir"/package.nix --ignore-same-hash
62''