1#! /usr/bin/env nix-shell
2#! nix-shell -i bash -p nix curl gnused -I nixpkgs=.
3
4# On Hackage every package description shows a category "Distributions" which
5# lists a "NixOS" version.
6# This script uploads a csv to hackage which will update the displayed versions
7# based on the current versions in nixpkgs. This happens with a simple http
8# request.
9
10# For authorization you just need to have any valid hackage account. This
11# script uses the `username` and `password-command` field from your
12# ~/.cabal/config file.
13
14# e.g. username: maralorn
15# password-command: pass hackage.haskell.org (this can be any command, but not an arbitrary shell expression. Like cabal we only read the first output line and ignore the rest.)
16# Those fields are specified under `upload` on the `cabal` man page.
17
18package_list="$(nix-build -A haskell.package-list)/nixos-hackage-packages.csv"
19username=$(grep "^username:" ~/.cabal/config | sed "s/^username: //")
20password_command=$(grep "^password-command:" ~/.cabal/config | sed "s/^password-command: //")
21curl -u "$username:$($password_command | head -n1)" --digest -H "Content-type: text/csv" -T "$package_list" http://hackage.haskell.org/distro/NixOS/packages.csv
22echo