-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
102 changed files
with
7,605 additions
and
6,458 deletions.
There are no files selected for viewing
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
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
37 changes: 37 additions & 0 deletions
37
maintainers/scripts/haskell/regenerate-hackage-packages.sh
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#! /usr/bin/env nix-shell | ||
#! nix-shell -i bash -p coreutils haskellPackages.cabal2nix-unstable git nix -I nixpkgs=. | ||
|
||
# This script is used to regenerate nixpkgs' Haskell package set, using a tool | ||
# called hackage2nix. hackage2nix looks at the config files in | ||
# pkgs/development/haskell-modules/configuration-hackage2nix and generates | ||
# a Nix expression for package version specified there, using the Cabal files | ||
# from the Hackage database (available under all-cabal-hashes) and its | ||
# companion tool cabal2nix. | ||
# | ||
# Related scripts are update-hackage.sh, for updating the snapshot of the | ||
# Hackage database used by hackage2nix, and update-cabal2nix-unstable.sh, | ||
# for updating the version of hackage2nix used to perform this task. | ||
|
||
set -euo pipefail | ||
|
||
extraction_derivation='with import ./. {}; runCommand "unpacked-cabal-hashes" { } "tar xf ${all-cabal-hashes} --strip-components=1 --one-top-level=$out"' | ||
unpacked_hackage="$(nix-build -E "$extraction_derivation" --no-out-link)" | ||
config_dir=pkgs/development/haskell-modules/configuration-hackage2nix | ||
|
||
hackage2nix \ | ||
--hackage "$unpacked_hackage" \ | ||
--preferred-versions <(for n in "$unpacked_hackage"/*/preferred-versions; do cat "$n"; echo; done) \ | ||
--nixpkgs "$PWD" \ | ||
--config "$config_dir/main.yaml" \ | ||
--config "$config_dir/stackage.yaml" \ | ||
--config "$config_dir/broken.yaml" \ | ||
--config "$config_dir/transitive-broken.yaml" | ||
|
||
if [[ "${1:-}" == "--do-commit" ]]; then | ||
git add pkgs/development/haskell-modules/hackage-packages.nix | ||
git commit -F - << EOF | ||
hackage-packages.nix: Regenerate based on current config | ||
This commit has been generated by maintainers/scripts/haskell/regenerate-hackage-packages.sh | ||
EOF | ||
fi |
3 changes: 3 additions & 0 deletions
3
maintainers/scripts/haskell/regenerate-transitive-broken-packages.sh
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#! /usr/bin/env nix-shell | ||
#! nix-shell -i bash -p coreutils nix gnused -I nixpkgs=. | ||
echo -e $(nix-instantiate --eval --strict maintainers/scripts/haskell/transitive-broken-packages.nix) | sed 's/\"//' > pkgs/development/haskell-modules/configuration-hackage2nix/transitive-broken.yaml |
21 changes: 21 additions & 0 deletions
21
maintainers/scripts/haskell/transitive-broken-packages.nix
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
let | ||
nixpkgs = import ../../..; | ||
inherit (nixpkgs {}) pkgs lib; | ||
getEvaluating = x: | ||
builtins.attrNames ( | ||
lib.filterAttrs ( | ||
_: v: (builtins.tryEval (v.outPath or null)).success && lib.isDerivation v && !v.meta.broken | ||
) x | ||
); | ||
brokenDeps = lib.subtractLists | ||
(getEvaluating pkgs.haskellPackages) | ||
(getEvaluating (nixpkgs { config.allowBroken = true; }).haskellPackages); | ||
in | ||
'' | ||
# This file is automatically generated by | ||
# maintainers/scripts/haskell/regenerate-transitive-broken-packages.sh | ||
# It is supposed to list all haskellPackages that cannot evaluate because they | ||
# depend on a dependency marked as broken. | ||
dont-distribute-packages: | ||
${lib.concatMapStringsSep "\n" (x: " - ${x}") brokenDeps} | ||
'' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#! /usr/bin/env nix-shell | ||
#! nix-shell -i bash -p coreutils curl jq gnused haskellPackages.cabal2nix-unstable -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 | ||
echo '# This file defines cabal2nix-unstable, used by maintainers/scripts/haskell/regenerate-hackage-packages.sh.' > pkgs/development/haskell-modules/cabal2nix-unstable.nix | ||
cabal2nix "https://github.com/NixOS/cabal2nix/archive/$commit.tar.gz" | sed -e 's/version = ".*"/version = "'"unstable-$date"'"/' >> pkgs/development/haskell-modules/cabal2nix-unstable.nix |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#! /usr/bin/env nix-shell | ||
#! nix-shell -i bash -p nix curl jq nix-prefetch-github git gnused -I nixpkgs=. | ||
|
||
# See regenerate-hackage-packages.sh for details on the purpose of this script. | ||
|
||
set -euo pipefail | ||
|
||
pin_file=pkgs/data/misc/hackage/pin.json | ||
current_commit="$(jq -r .commit $pin_file)" | ||
old_date="$(jq -r .msg $pin_file | sed 's/Update from Hackage at //')" | ||
git_info="$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/commercialhaskell/all-cabal-hashes/branches/hackage)" | ||
head_commit="$(echo "$git_info" | jq -r .commit.sha)" | ||
commit_msg="$(echo "$git_info" | jq -r .commit.commit.message)" | ||
new_date="$(echo "$commit_msg" | sed 's/Update from Hackage at //')" | ||
|
||
if [ "$current_commit" != "$head_commit" ]; then | ||
url="https://github.com/commercialhaskell/all-cabal-hashes/archive/$head_commit.tar.gz" | ||
hash="$(nix-prefetch-url "$url")" | ||
jq -n \ | ||
--arg commit "$head_commit" \ | ||
--arg hash "$hash" \ | ||
--arg url "$url" \ | ||
--arg commit_msg "$commit_msg" \ | ||
'{commit: $commit, url: $url, sha256: $hash, msg: $commit_msg}' \ | ||
> $pin_file | ||
fi | ||
|
||
if [[ "${1:-}" == "--do-commit" ]]; then | ||
git add pkgs/data/misc/hackage/pin.json | ||
git commit -F - << EOF | ||
all-cabal-hashes: $old_date -> $new_date | ||
This commit has been generated by maintainers/scripts/haskell/update-hackage.sh | ||
EOF | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#! /usr/bin/env nix-shell | ||
#! nix-shell -i bash -p nix curl jq nix-prefetch-github git gnused gnugrep -I nixpkgs=. | ||
|
||
set -eu -o pipefail | ||
|
||
tmpfile=$(mktemp "update-stackage.XXXXXXX") | ||
# shellcheck disable=SC2064 | ||
|
||
stackage_config="pkgs/development/haskell-modules/configuration-hackage2nix/stackage.yaml" | ||
|
||
trap "rm ${tmpfile} ${tmpfile}.new" 0 | ||
touch "$tmpfile" "$tmpfile.new" # Creating files here so that trap creates no errors. | ||
|
||
curl -L -s "https://stackage.org/nightly/cabal.config" >"$tmpfile" | ||
old_version=$(grep "# Stackage Nightly" $stackage_config | sed -E 's/.*([0-9]{4}-[0-9]{2}-[0-9]{2}).*/\1/') | ||
version=$(sed -rn "s/^--.*http:..(www.)?stackage.org.snapshot.nightly-//p" "$tmpfile") | ||
|
||
if [[ "$old_version" == "$version" ]]; then | ||
echo "No new stackage version" | ||
exit 0 # Nothing to do | ||
fi | ||
|
||
# Create a simple yaml version of the file. | ||
sed -r \ | ||
-e '/^--/d' \ | ||
-e 's|^constraints:||' \ | ||
-e 's|^ +| - |' \ | ||
-e 's|,$||' \ | ||
-e '/installed$/d' \ | ||
-e '/^$/d' \ | ||
< "${tmpfile}" | sort --ignore-case >"${tmpfile}.new" | ||
|
||
cat > $stackage_config << EOF | ||
# Stackage Nightly $version | ||
# This file is auto-generated by | ||
# maintainers/scripts/haskell/update-stackage.sh | ||
default-package-overrides: | ||
EOF | ||
|
||
# Drop restrictions on some tools where we always want the latest version. | ||
sed -r \ | ||
-e '/ cabal-install /d' \ | ||
-e '/ cabal2nix /d' \ | ||
-e '/ cabal2spec /d' \ | ||
-e '/ distribution-nixpkgs /d' \ | ||
-e '/ git-annex /d' \ | ||
-e '/ hindent /d' \ | ||
-e '/ hledger/d' \ | ||
-e '/ hlint /d' \ | ||
-e '/ hoogle /d' \ | ||
-e '/ hopenssl /d' \ | ||
-e '/ jailbreak-cabal /d' \ | ||
-e '/ json-autotype/d' \ | ||
-e '/ language-nix /d' \ | ||
-e '/ shake /d' \ | ||
-e '/ ShellCheck /d' \ | ||
-e '/ stack /d' \ | ||
-e '/ weeder /d' \ | ||
< "${tmpfile}.new" >> $stackage_config | ||
|
||
if [[ "${1:-}" == "--do-commit" ]]; then | ||
git add $config_file | ||
git commit -F - << EOF | ||
Stackage Nightly: $old_version -> $version | ||
This commit has been generated by maintainers/scripts/haskell/update-stackage.sh | ||
EOF | ||
fi |
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
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
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
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
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
Oops, something went wrong.