Created
September 14, 2021 06:23
-
-
Save cdepillabout/9178e32d070ab62814f68299519a6870 to your computer and use it in GitHub Desktop.
demonstrate how to fetch URL imports in Dhall by turning the integrity checks into Nix fixed-output-derivations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with import <nixpkgs> {}; | |
let | |
packageSet = fetchurl { | |
url = "https://github.com/purescript/package-sets/releases/download/psc-0.14.4-20210905/packages.dhall"; | |
# The hash below is a base64-encoded version of the base-16 hash that is | |
# specified in our local packages.dhall file: | |
# ``` | |
# $ cat packages.dhall | |
# let upstream = | |
# https://github.com/purescript/package-sets/releases/download/psc-0.14.4-20210905/packages.dhall sha256:140f3630801f2b02d5f3a405d4872e0af317e4ef187016a6b00f97d59d6275c6 | |
# in upstream | |
# ``` | |
# | |
# So sha256-FA82MIAfKwLV86QF1IcuCvMX5O8YcBamsA+X1Z1idcY= is the base64-encoded version of | |
# 140f3630801f2b02d5f3a405d4872e0af317e4ef187016a6b00f97d59d6275c6 (which is base16-encoded). | |
# This proves that we can turn URL references in dhall into a FOD in | |
# Nix (as long as the URL references has an integrity check). | |
hash = "sha256-FA82MIAfKwLV86QF1IcuCvMX5O8YcBamsA+X1Z1idcY="; | |
downloadToTemp = true; | |
postFetch = '' | |
${dhall}/bin/dhall encode --file "$downloadedFile" > $out | |
''; | |
}; | |
decodedPackageSet = runCommand "decodedPackageSet" {} '' | |
${dhall}/bin/dhall decode --file "${packageSet}" > $out | |
''; | |
in | |
dhallToNix (builtins.readFile decodedPackageSet) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This Nix file demonstrates how Dhall URLs with integrity checks can be turned into Nix fixed-output derivations (FODs).
This Nix file can be evaluated like the following:
<nixpkgs>
is currently pointing to21.05.2549.a1007637cea
.