Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an optional hash parameter to builtins.fetchGit #3216

Closed
wants to merge 1 commit into from

Commits on Dec 21, 2019

  1. Add an optional hash parameter to builtins.fetchGit

    This is particularly useful to ensure the purity e.g. of a repo which is
    pinned to a git tag (tags can be force-pushed which makes builds silently irreproducible)
    or when trying to evaluate a nix expression without internet connectivity (if the
    cache-entry is expired, the eval will break as the git repo can't be re-fetched).
    
    This change adds an optional `hash` parameter (with an SRI-hash[1]) to the builtin
    `fetchGit` and checks if there's a content-addressable path which matches the hash
    (the hash can be determined using `nix to-sri --type sha256 $(nix-prefetch-git ...)`).
    
    If no such path exists, it will be attempted to fetch the Git repository in
    order to compare the hashes. Please note that caching is still used here, so
    if the repo is already fetched and the only hash in the expression changes,
    the evaluation will fail pretty fast.
    
    [1] https://www.w3.org/TR/SRI/
    Ma27 committed Dec 21, 2019
    Configuration menu
    Copy the full SHA
    24e14cc View commit details
    Browse the repository at this point in the history