Skip to content

Commit

Permalink
Build nonReinstallablePkgs from pre-existing packages in plan.json (#…
Browse files Browse the repository at this point in the history
…2207)

Haskell.nix now respects the `pre-existing` packages selected
by the cabal planner.  The selection made by the planner
is used to set `nonReinstallablePkgs`.

Instead setting `nonReinstallablePkgs` and `reinstallableLibGhc`
haskell.nix projects should add `constraints` to the cabal project.

For instance to force the use of the `pre-exising` `text`
package add:

```
  constraints: text installed
```

To make sure `text` is reinstalled use:

```
  constraints: text source
```

The `pre-existing` `ghc` will now be used by default as
that is what `cabal` will choose (haskell.nix used to choose
`reinstallableLibGhc=true` by default).

To allow cabal to choose reinstalling `ghc` add:

```
  allow-boot-library-installs: True
```

To force cabal to choose reinstalling:

```
  constraints: ghc source
  allow-boot-library-installs: True
```

It may also need `allow-newer: ghc:Cabal`
  • Loading branch information
hamishmack authored Jun 4, 2024
1 parent de29feb commit adc2e66
Show file tree
Hide file tree
Showing 464 changed files with 12,758 additions and 13,164 deletions.
2 changes: 1 addition & 1 deletion builder/make-config-files.nix
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ let
fi
''}
done
for p in ${lib.concatStringsSep " " (lib.remove "ghc" nonReinstallablePkgs')}; do
for p in ${lib.concatStringsSep " " nonReinstallablePkgs'}; do
if [ -e $ghcDeps/envDeps/$p ]; then
cat $ghcDeps/envDeps/$p >> $configFiles/ghc-environment
fi
Expand Down
41 changes: 41 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,47 @@
This file contains a summary of changes to Haskell.nix and `nix-tools`
that will impact users.

## Jun 5, 2024

Haskell.nix now respects the `pre-existing` packages selected
by the cabal planner. The selection made by the planner
is used to set `nonReinstallablePkgs`.

Instead setting `nonReinstallablePkgs` and `reinstallableLibGhc`
haskell.nix projects should add `constraints` to the cabal project.

For instance to force the use of the `pre-exising` `text`
package add:

```
constraints: text installed
```

To make sure `text` is reinstalled use:

```
constraints: text source
```

The `pre-existing` `ghc` will now be used by default as
that is what `cabal` will choose (haskell.nix used to choose
`reinstallableLibGhc=true` by default).

To allow cabal to choose reinstalling `ghc` add:

```
allow-boot-library-installs: True
```

To force cabal to choose reinstalling:

```
constraints: ghc source
allow-boot-library-installs: True
```

It may also need `allow-newer: ghc:Cabal`

## Mar 27, 2023

Haskell.nix will no longer parse the `cabal.project` file to
Expand Down
6 changes: 6 additions & 0 deletions compiler/ghc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,16 @@ let
materialized =
if builtins.compareVersions ghc-version "9.4" < 0
then ../../materialized/${compiler-nix-name}/hadrian-ghc92
else if builtins.compareVersions ghc-version "9.4.8" < 0
then ../../materialized/${compiler-nix-name}/hadrian-ghc947
else if builtins.compareVersions ghc-version "9.6" < 0
then ../../materialized/${compiler-nix-name}/hadrian-ghc94
else if builtins.compareVersions ghc-version "9.6.5" < 0
then ../../materialized/${compiler-nix-name}/hadrian-ghc964
else if builtins.compareVersions ghc-version "9.8" < 0
then ../../materialized/${compiler-nix-name}/hadrian-ghc96
else if builtins.compareVersions ghc-version "9.8.2" < 0
then ../../materialized/${compiler-nix-name}/hadrian-ghc981
else if builtins.compareVersions ghc-version "9.9" < 0
then ../../materialized/${compiler-nix-name}/hadrian-ghc98
else ../../materialized/${compiler-nix-name}/hadrian-ghc99;
Expand Down
33 changes: 18 additions & 15 deletions lib/call-cabal-project-to-nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -363,46 +363,49 @@ let

ghc-pkgs = [
"Cabal"
"Cabal-syntax"
"array"
"base"
"binary"
"bytestring"
"containers"
"deepseq"
"directory"
"exceptions"
"filepath"
"ghc"
"ghc-bignum"
"ghc-boot"
"ghc-boot-th"
"ghc-compact"
"ghc-experimental"
"ghc-heap"
"ghc-internal"
"ghc-platform"
"ghc-prim"
"ghc-toolchain"
"ghci"
"haskeline"
"hpc"
"integer-gmp"
"libiserv"
"mtl"
"os-string"
"parsec"
"pretty"
"process"
"rts"
"semaphore-compat"
"stm"
"template-haskell"
"terminfo"
"text"
"time"
"transformers"
] ++ pkgs.lib.optionals (!pkgs.stdenv.targetPlatform.isGhcjs || builtins.compareVersions ghc.version "9.0" > 0) [
# GHCJS 8.10 does not have these
"Cabal-syntax"
"exceptions"
"ghc"
"ghc-bignum"
"ghc-experimental"
"ghc-internal"
"ghc-platform"
"ghc-toolchain"
"haskeline"
"hpc"
"libiserv"
"os-string"
"semaphore-compat"
"stm"
"xhtml"
] ++ pkgs.lib.optionals (!pkgs.stdenv.targetPlatform.isGhcjs) [
"terminfo"
] ++ (if pkgs.stdenv.targetPlatform.isWindows
then [ "Win32" ]
else [ "unix" ]
Expand Down
14 changes: 13 additions & 1 deletion lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,19 @@ in {

# Converts from a `compoent.depends` value to a library derivation.
# In the case of sublibs the `depends` value should already be the derivation.
dependToLib = d: d.components.library or d;
dependToLib = d:
# Do simplify this to `d.components.library or d`, as that
# will not give a good error message if the `.library`
# is missing (happens if the package is unplanned,
# but has overrides).
# It would be nice to put an `assert` here, but there is
# currently no good way to get the name of the dependency
# when it is not in the plan. The attribute path of
# `d` in the `nix` error should include the name
# eg. `packages.Cabal.components.library`.
if d ? components
then d.components.library
else d;

projectOverlays = import ./project-overlays.nix {
inherit lib haskellLib;
Expand Down
16 changes: 16 additions & 0 deletions materialized/alex-3.2.7.1/default.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions materialized/ghc-boot-packages-nix/ghc8107-ghcjs/Win32.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions materialized/ghc-boot-packages-nix/ghc8107-ghcjs/base.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions materialized/ghc-boot-packages-nix/ghc8107-ghcjs/ghc-boot.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions materialized/ghc-boot-packages-nix/ghc8107-ghcjs/ghc-heap.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions materialized/ghc-boot-packages-nix/ghc8107-ghcjs/ghc-prim.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions materialized/ghc-boot-packages-nix/ghc8107-ghcjs/ghci.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions materialized/ghc-boot-packages-nix/ghc8107-ghcjs/hpc.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit adc2e66

Please sign in to comment.