1{ indexStateHashesPath, nix-tools, coreutils, nix, writeShellScriptBin, stdenv, curl }:
4writeShellScriptBin "update-index-state-hashes" ''
5 export PATH="${makeBinPath [ coreutils nix-tools nix curl ]}"
7 # We'll take the last element from the indexStatesHashes file via nix and get the name.
8 # This is the last timestamp recorded in the file (implicit assumption: the file is
9 # ordered, and nix preserved that order when parsing it into a attributeset).
10 start=${let ls = attrNames (import indexStateHashesPath); in elemAt ls (length ls - 1)}
12 # The indexStatesHashesPath looks like
16 # Idea: take everything but drop the last line, and can then just append each new
17 # entry and finally close the file with "}". We'll do this by echoing to STDOUT!
19 # Old file without the closing curly brace.
20 cat ${indexStateHashesPath} | head -n -1
22 # Parse the $start date, and now into seconds with the date command. Then walk
23 # them by 86400 (24*60*60) days. We need to format the output with '%.f' as we
24 # don't want fractional values.
25 for d in $(seq -f '%.f' $(date -u +%s -d $start) 86400 $(date -u +%s)) ; do
26 # turn the step date $d into a YYYY-MM-DD string, and generate the truncated
27 # index, compute it's hash and echo "$dT00:00:00Z" = "$sha256"; to STDOUT.
28 dt=$(date -u +%Y-%m-%d -d @$d)
30 # ensure we don't generate the $start date twice (skip the first invocation).
31 if [[ "''${dt}T00:00:00Z" != "$start" ]]; then
32 curl "https://hackage.haskell.org/01-index.tar.gz" --output index.tar.gz --fail-early
33 truncate-index -o ''${dt}-01-index.tar.gz -i index.tar.gz -s "''${dt}T00:00:00Z"
34 sha256=$(nix-hash --flat --type sha256 ''${dt}-01-index.tar.gz)
35 echo " \"''${dt}T00:00:00Z\" = \"''${sha256}\";"
39 # emit the final closing brace.
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list