You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
773 B

2 years ago
  1. #!/usr/bin/env nix-shell
  2. #! nix-shell -i bash -p curl jq nix
  3. #
  4. # Updates nixpkgs.json to the latest or chosen nixpkgs revision
  5. #
  6. # Usage: ./update-nix
  7. # ./update-nix $rev
  8. # ./update-nix $owner $rev
  9. #
  10. # Arguments default to owner=nixos and rev=master and refer
  11. # to the github owner of a nixpkgs fork and a git revision.
  12. #
  13. set -exo pipefail
  14. owner="nixos"
  15. if [ ! -z "$2" ]; then
  16. owner="$1"
  17. rev="$2"
  18. else
  19. rev="${1:-master}"
  20. fi
  21. resolved_rev=$(curl "https://api.github.com/repos/${owner}/nixpkgs/commits?sha=${rev}" | jq -r 'first.sha')
  22. url="https://github.com/${owner}/nixpkgs/archive/${resolved_rev}.tar.gz"
  23. digest=$(nix-prefetch-url --unpack "$url")
  24. echo "{\"url\": \"${url}\", \"sha256\": \"${digest}\"}" | jq '.' > nix/nixpkgs.json