-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-nixpkgs
executable file
·56 lines (33 loc) · 1.17 KB
/
update-nixpkgs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
set -euxo pipefail
fail() {
>&2 echo "$1"
exit 1
}
[[ -v 1 ]] || fail "No version specified. Halting"
VERSION="$1"
LOCAL_REPO="${LOCAL_REPO:-/workplace/hiljusti/nixpkgs}"
cd "$LOCAL_REPO" || fail "Couldn't change to $LOCAL_REPO"
git checkout master
git pull upstream master && git push
BRANCH="update/sigi-$VERSION"
git branch -D "$BRANCH" || true
git checkout -b "$BRANCH"
PKG=./pkgs/by-name/si/sigi/package.nix
OLDVERSION="$(grep -E 'version' "$PKG" | head -n 1 | sed 's/";//' | sed -E 's/.+"//')"
sed -i -E "s/version = \".+/version = \"$VERSION\";/" "$PKG"
SHASUM="$(not nix-env -iA sigi -f . 2>&1 | tee | grep got: | sed -E 's/.+sha/sha/')"
sed -i -E "s/hash = .+/hash = \"${SHASUM//\//\\\/}\";/" "$PKG"
CARGO_SHASUM="$(not nix-env -iA sigi -f . 2>&1 | tee | grep got: | sed -E 's/.+sha/sha/')"
sed -i -E "s/cargoHash = .+/cargoHash = \"${CARGO_SHASUM//\//\\\/}\";/" "$PKG"
nix-env -iA sigi -f .
git add "$PKG"
COMMIT_MSG="sigi: $OLDVERSION -> $VERSION"
git commit -m "$COMMIT_MSG"
git push -u origin "$BRANCH"
gh pr create \
--draft \
--title "$COMMIT_MSG" \
--repo NixOS/nixpkgs
git checkout master
git branch -D "update/sigi-$VERSION" || true