lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 23.11-beta 98 lines 3.3 kB view raw
1{ cacert, dhall, dhall-docs, haskell, lib, runCommand }: 2 3# `buildDhallUrl` is similar to `buildDhallDirectoryPackage` or 4# `buildDhallGitHubPackage`, but instead builds a Nixpkgs Dhall package 5# based on a hashed URL. This will generally be a URL that has an integrity 6# check in a Dhall file. 7# 8# Similar to `buildDhallDirectoryPackage` and `buildDhallGitHubPackage`, the output 9# of this function is a derivation that has a `binary.dhall` file, along with 10# a `.cache/` directory with the actual contents of the Dhall file from the 11# suppiled URL. 12# 13# This function is primarily used by `dhall-to-nixpkgs directory --fixed-output-derivations`. 14 15{ # URL of the input Dhall file. 16 # example: "https://raw.githubusercontent.com/cdepillabout/example-dhall-repo/c1b0d0327146648dcf8de997b2aa32758f2ed735/example1.dhall" 17 url 18 19 # Nix hash of the input Dhall file. 20 # example: "sha256-ZTSiQUXpPbPfPvS8OeK6dDQE6j6NbP27ho1cg9YfENI=" 21, hash 22 23 # Dhall hash of the input Dhall file. 24 # example: "sha256:6534a24145e93db3df3ef4bc39e2ba743404ea3e8d6cfdbb868d5c83d61f10d2" 25, dhallHash 26 27 # Name for this derivation. 28, name ? (baseNameOf url + "-cache") 29 30 # `buildDhallUrl` can include both a "source distribution" in 31 # `source.dhall` and a "binary distribution" in `binary.dhall`: 32 # 33 # * `source.dhall` is a dependency-free αβ-normalized Dhall expression 34 # 35 # * `binary.dhall` is an expression of the form: `missing sha256:${HASH}` 36 # 37 # This expression requires you to install the cache product located at 38 # `.cache/dhall/1220${HASH}` to successfully resolve 39 # 40 # By default, `buildDhallUrl` only includes "binary.dhall" to conserve 41 # space within the Nix store, but if you set the following `source` option to 42 # `true` then the package will also include `source.dhall`. 43, source ? false 44}: 45 46let 47 # HTTP support is disabled in order to force that HTTP dependencies are built 48 # using Nix instead of using Dhall's support for HTTP imports. 49 dhallNoHTTP = haskell.lib.appendConfigureFlag dhall "-f-with-http"; 50 51 # This uses Dhall's remote importing capabilities for downloading a Dhall file. 52 # The output Dhall file has all imports resolved, and then is 53 # alpha-normalized and binary-encoded. 54 downloadedEncodedFile = 55 runCommand 56 (baseNameOf url) 57 { 58 outputHashAlgo = null; 59 outputHash = hash; 60 name = baseNameOf url; 61 nativeBuildInputs = [ cacert ]; 62 impureEnvVars = lib.fetchers.proxyImpureEnvVars; 63 } 64 '' 65 echo "${url} ${dhallHash}" > in-dhall-file 66 ${dhall}/bin/dhall --alpha --plain --file in-dhall-file | ${dhallNoHTTP}/bin/dhall encode > $out 67 ''; 68 69 cache = ".cache"; 70 71 data = ".local/share"; 72 73 cacheDhall = "${cache}/dhall"; 74 75 dataDhall = "${data}/dhall"; 76 77 sourceFile = "source.dhall"; 78 79in 80 runCommand name { } 81 ('' 82 set -eu 83 84 mkdir -p ${cacheDhall} $out/${cacheDhall} 85 86 export XDG_CACHE_HOME=$PWD/${cache} 87 88 SHA_HASH="${dhallHash}" 89 90 HASH_FILE="''${SHA_HASH/sha256:/1220}" 91 92 cp ${downloadedEncodedFile} $out/${cacheDhall}/$HASH_FILE 93 94 echo "missing $SHA_HASH" > $out/binary.dhall 95 '' + 96 lib.optionalString source '' 97 ${dhallNoHTTP}/bin/dhall decode --file ${downloadedEncodedFile} > $out/${sourceFile} 98 '')