env setup (#6)

This commit is contained in:
zhenfei
2022-04-20 17:10:25 -04:00
committed by GitHub
parent 5b2265b633
commit 9d4d178455
25 changed files with 605 additions and 0 deletions

27
nix/update-nix Executable file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p curl jq nix
#
# Updates nixpkgs.json to the latest or chosen nixpkgs revision
#
# Usage: ./update-nix
# ./update-nix $rev
# ./update-nix $owner $rev
#
# Arguments default to owner=nixos and rev=master and refer
# to the github owner of a nixpkgs fork and a git revision.
#
set -exo pipefail
owner="nixos"
if [ ! -z "$2" ]; then
owner="$1"
rev="$2"
else
rev="${1:-master}"
fi
resolved_rev=$(curl "https://api.github.com/repos/${owner}/nixpkgs/commits?sha=${rev}" | jq -r 'first.sha')
url="https://github.com/${owner}/nixpkgs/archive/${resolved_rev}.tar.gz"
digest=$(nix-prefetch-url --unpack "$url")
echo "{\"url\": \"${url}\", \"sha256\": \"${digest}\"}" | jq '.' > nix/nixpkgs.json