Skip to content

Commit

Permalink
fix #269. Apply fix to mkStackPkgSet
Browse files Browse the repository at this point in the history
First fix only fixed `haskell-nix.snapshot` by applying the fix also
to mkStackPkgSet stack.yaml based projects should work with lts 14
  • Loading branch information
hamishmack committed Nov 8, 2019
1 parent be5ce45 commit 1461517
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
16 changes: 14 additions & 2 deletions overlays/haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ self: super: {
inherit hackage pkg-def;
});

# Some boot packages (libiserv) are in lts, but not in hackage,
# so we should not try to get it from hackage based on the stackage
# info. Instead we can add ghc-boot-packages to `pkg-def-extras`.
excludeBootPackages = pkg-def: hackage:
let original = pkg-def hackage;
bootPkgNames = self.lib.attrNames
self.ghc-boot-packages.${(pkg-def hackage).compiler.nix-name};
in original // {
packages = self.lib.filterAttrs (n: _: self.lib.all (b: n != b) bootPkgNames)
original.packages;
};

# Create a Haskell package set based on a Stack configuration.
mkStackPkgSet =
{ stack-pkgs # Path to the output of stack-to-nix
Expand All @@ -92,7 +104,7 @@ self: super: {
compiler = (stack-pkgs.extras hackage).compiler or (pkg-def hackage).compiler;
patchesModule = ghcHackagePatches.${compiler.nix-name} or {};
in mkPkgSet {
inherit pkg-def;
pkg-def = excludeBootPackages pkg-def;
pkg-def-extras = [ stack-pkgs.extras
self.ghc-boot-packages.${compiler.nix-name}
]
Expand Down Expand Up @@ -130,7 +142,7 @@ self: super: {
};

# Package sets for all stackage snapshots.
snapshots = import ../snapshots.nix { inherit (self) lib ghc-boot-packages; inherit mkPkgSet stackage; };
snapshots = import ../snapshots.nix { inherit (self) lib excludeBootPackages ghc-boot-packages; inherit mkPkgSet stackage; };
# Pick a recent LTS snapshot to be our "default" package set.
haskellPackages = snapshots."lts-14.13";

Expand Down
14 changes: 2 additions & 12 deletions snapshots.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,13 @@
# A particular package in a snapshot would be accessed with:
# snapshots."lts-13.18".conduit

{ lib, mkPkgSet, stackage, ghc-boot-packages }:
{ lib, mkPkgSet, stackage, excludeBootPackages, ghc-boot-packages }:

with lib;

let
mkSnapshot = name: pkg-def: (let pkgSet = mkPkgSet {
# Some boot packages (libiserv) are in lts, but not in hackage,
# so we should not try to get it from hackage based on the stackage
# info. Instead we can add ghc-boot-packages to `pkg-def-extras`.
pkg-def = hackage:
let original = pkg-def hackage;
bootPkgNames = lib.attrNames
ghc-boot-packages.${(pkg-def hackage).compiler.nix-name};
in original // {
packages = lib.filterAttrs (n: _: lib.all (b: n != b) bootPkgNames)
original.packages;
};
pkg-def = excludeBootPackages pkg-def;
# ghc-boot-packages are needed for the reinstallable ghc library and
# are constructed from the patched ghc source.
pkg-def-extras = (pkg-def-extras name)
Expand Down
2 changes: 1 addition & 1 deletion test/stack-simple/pkgs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
stack-simple = ./stack-simple.nix;
};
};
resolver = "lts-13.26";
resolver = "lts-14.13";
modules = [ ({ lib, ... }: { packages = {}; }) { packages = {}; } ];
}
2 changes: 1 addition & 1 deletion test/stack-simple/stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
# resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml
resolver: lts-13.26
resolver: lts-14.13

# User packages to be built.
# Various formats can be used as shown in the example below.
Expand Down

0 comments on commit 1461517

Please sign in to comment.