summary refs log tree commit diff
diff options
context:
space:
mode:
authorsternenseemann <sternenseemann@systemli.org>2023-02-19 11:55:51 +0100
committersternenseemann <sternenseemann@systemli.org>2023-02-19 19:52:17 +0100
commitb7e41b825ea3b2f897112c7f0810508b0e8b9d5e (patch)
treea66eec9ed51fc7ef192f1dcbeb8f7cc713197cb9
parent16078721aae76dee5b82f643eb211fa7b9aa0796 (diff)
downloadnixpkgs-b7e41b825ea3b2f897112c7f0810508b0e8b9d5e.tar
nixpkgs-b7e41b825ea3b2f897112c7f0810508b0e8b9d5e.tar.gz
nixpkgs-b7e41b825ea3b2f897112c7f0810508b0e8b9d5e.tar.bz2
nixpkgs-b7e41b825ea3b2f897112c7f0810508b0e8b9d5e.tar.lz
nixpkgs-b7e41b825ea3b2f897112c7f0810508b0e8b9d5e.tar.xz
nixpkgs-b7e41b825ea3b2f897112c7f0810508b0e8b9d5e.tar.zst
nixpkgs-b7e41b825ea3b2f897112c7f0810508b0e8b9d5e.zip
maintainers/haskell: generate core-pkgs hackage2nix configuration
`ghc-pkg list` tells us everything hackage2nix needs to know. In the
past the core-packages list and compiler setting in hackage2nix was
maintained manually which inevitably leads to it being forgot once in a
while – this will then mess with flag resolution when generating the
package set in some cases. Luckily, we can just let a simple derivation
do this for us.

Resolves #202621.
-rwxr-xr-xmaintainers/scripts/haskell/regenerate-hackage-packages.sh11
-rw-r--r--pkgs/development/haskell-modules/configuration-common.nix33
-rw-r--r--pkgs/development/haskell-modules/configuration-hackage2nix/main.yaml46
3 files changed, 43 insertions, 47 deletions
diff --git a/maintainers/scripts/haskell/regenerate-hackage-packages.sh b/maintainers/scripts/haskell/regenerate-hackage-packages.sh
index 9d51eb4ca4a..5e6b5a888ad 100755
--- a/maintainers/scripts/haskell/regenerate-hackage-packages.sh
+++ b/maintainers/scripts/haskell/regenerate-hackage-packages.sh
@@ -11,6 +11,9 @@
 # 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.
+#
+# Note that this script doesn't gcroot anything, so it may be broken by an
+# unfortunately timed nix-store --gc.
 
 set -euo pipefail
 
@@ -20,15 +23,21 @@ HACKAGE2NIX="${HACKAGE2NIX:-hackage2nix}"
 # See: https://github.com/NixOS/nixpkgs/pull/122023
 export LC_ALL=C.UTF-8
 
+config_dir=pkgs/development/haskell-modules/configuration-hackage2nix
+
+echo "Obtaining Hackage data"
 extraction_derivation='with import ./. {}; runCommandLocal "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
+
+echo "Generating compiler configuration"
+compiler_config="$(nix-build -A haskellPackages.cabal2nix-unstable.compilerConfig --no-out-link)"
 
 echo "Starting hackage2nix to regenerate pkgs/development/haskell-modules/hackage-packages.nix ..."
 "$HACKAGE2NIX" \
    --hackage "$unpacked_hackage" \
    --preferred-versions <(for n in "$unpacked_hackage"/*/preferred-versions; do cat "$n"; echo; done) \
    --nixpkgs "$PWD" \
+   --config "$compiler_config" \
    --config "$config_dir/main.yaml" \
    --config "$config_dir/stackage.yaml" \
    --config "$config_dir/broken.yaml" \
diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix
index aed5bc3ac24..8a73d0efa64 100644
--- a/pkgs/development/haskell-modules/configuration-common.nix
+++ b/pkgs/development/haskell-modules/configuration-common.nix
@@ -1815,7 +1815,38 @@ self: super: {
   database-id-class = doJailbreak super.database-id-class;
 
   cabal2nix-unstable = overrideCabal {
-    passthru.updateScript = ../../../maintainers/scripts/haskell/update-cabal2nix-unstable.sh;
+    passthru = {
+      updateScript = ../../../maintainers/scripts/haskell/update-cabal2nix-unstable.sh;
+
+      # This is used by regenerate-hackage-packages.nix to supply the configuration
+      # values we can easily generate automatically without checking them in.
+      compilerConfig =
+        pkgs.runCommand
+          "hackage2nix-${self.ghc.haskellCompilerName}-config.yaml"
+          {
+            nativeBuildInputs = [
+              self.ghc
+            ];
+          }
+          ''
+            cat > "$out" << EOF
+            # generated by haskellPackages.cabal2nix-unstable.compilerConfig
+            compiler: ${self.ghc.haskellCompilerName}
+
+            core-packages:
+              # Hack: The following package is a core package of GHCJS. If we don't declare
+              # it, then hackage2nix will generate a Hackage database where all dependants
+              # of this library are marked as "broken".
+              - ghcjs-base-0
+
+            EOF
+
+            ghc-pkg list \
+              | tail -n '+2' \
+              | sed -e 's/[()]//g' -e 's/\s\+/  - /' \
+              >> "$out"
+          '';
+    };
   } super.cabal2nix-unstable;
 
   # Too strict version bounds on base
diff --git a/pkgs/development/haskell-modules/configuration-hackage2nix/main.yaml b/pkgs/development/haskell-modules/configuration-hackage2nix/main.yaml
index f6795d8fa61..ecd8e4dae16 100644
--- a/pkgs/development/haskell-modules/configuration-hackage2nix/main.yaml
+++ b/pkgs/development/haskell-modules/configuration-hackage2nix/main.yaml
@@ -1,48 +1,4 @@
-# pkgs/development/haskell-modules/configuration-hackage2nix.yaml
-
-compiler: ghc-9.2.4
-
-core-packages:
-  - Cabal-3.6.3.0
-  - array-0.5.4.0
-  - base-4.16.3.0
-  - binary-0.8.9.0
-  - bytestring-0.11.3.1
-  - containers-0.6.5.1
-  - deepseq-1.4.6.1
-  - directory-1.3.6.2
-  - exceptions-0.10.4
-  - filepath-1.4.2.2
-  - ghc-9.2.4
-  - ghc-bignum-1.2
-  - ghc-boot-9.2.4
-  - ghc-boot-th-9.2.4
-  - ghc-compact-0.1.0.0
-  - ghc-heap-9.2.4
-  - ghc-prim-0.8.0
-  - ghci-9.2.4
-  - haskeline-0.8.2
-  - hpc-0.6.1.0
-  - integer-gmp-1.1
-  - libiserv-9.2.4
-  - mtl-2.2.2
-  - parsec-3.1.15.0
-  - pretty-1.1.3.6
-  - process-1.6.13.2
-  - rts-1.0.2
-  - stm-2.5.0.2
-  - template-haskell-2.18.0.0
-  - terminfo-0.4.1.5
-  - text-1.2.5.0
-  - time-1.11.1.1
-  - transformers-0.5.6.2
-  - unix-2.7.2.2
-  - xhtml-3000.2.2.1
-
-  # Hack: The following package is a core package of GHCJS. If we don't declare
-  # it, then hackage2nix will generate a Hackage database where all dependants
-  # of this library are marked as "broken".
-  - ghcjs-base-0
+# pkgs/development/haskell-modules/configuration-hackage2nix/main.yaml
 
 # This is a list of packages with versions from the latest Stackage LTS release.
 #