mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-11-10 01:33:11 +01:00
cabal2nix-unstable is mostly used for regenerating the Haskell package set. Thus we should aim to make it quick to rebuild in case its hash changes because of Haskell related changes. - cabal2nix is not fussy about the Nix version it uses for nix-env(1) and we can just assume it is already in PATH like we do for maintainers/scripts/haskell/*. - nix-prefetch-scripts causes the most trouble since its python dependencies depend on pandoc, so many Haskell changes require an additional Python rebuild when building cabal2nix-unstable. nix-prefetch-scripts is most likely installed and not necessary in many cases, e.g. hackage2nix doesn't need them which is the main use we have for cabal2nix-unstable. For the update scripts that do need them, we add them to the used nix-shell explicitly.
20 lines
1.1 KiB
Bash
Executable file
20 lines
1.1 KiB
Bash
Executable file
#! /usr/bin/env nix-shell
|
|
#! nix-shell -i bash -p coreutils curl jq gnused haskellPackages.cabal2nix-unstable.bin nix-prefetch-scripts -I nixpkgs=.
|
|
|
|
# Updates cabal2nix-unstable to the latest master of the nixos/cabal2nix repository.
|
|
# See regenerate-hackage-packages.sh for details on the purpose of this script.
|
|
|
|
set -euo pipefail
|
|
|
|
# fetch current master HEAD from Github
|
|
head_info="$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/NixOS/cabal2nix/branches/master)"
|
|
# extract commit hash
|
|
commit="$(jq -r .commit.sha <<< "$head_info")"
|
|
# extract commit timestamp and convert to date
|
|
date="$(date "--date=$(jq -r .commit.commit.committer.date <<< "$head_info")" +%F)"
|
|
# generate nix expression from cabal file, replacing the version with the commit date
|
|
output=pkgs/development/haskell-modules/cabal2nix-unstable.nix
|
|
echo '# This file defines cabal2nix-unstable, used by maintainers/scripts/haskell/regenerate-hackage-packages.sh.' > "$output"
|
|
cabal2nix --subpath cabal2nix "https://github.com/NixOS/cabal2nix/archive/$commit.tar.gz" | sed -e 's/version = ".*"/version = "'"unstable-$date"'"/' >> "$output"
|
|
nixfmt "$output"
|