on iko/ghcjs-patch-master help sign in
Simplify the way evalPackages works (#1162)

This change uses the same overlay for both flakes and non flake projects. It chooses where evalPackages should run based on `builtins ? currentSystem` (`currentSystem` will not exist when building flake). This will be needed to make sure the `evalPackages` still works correctly in #1151 (otherwise the use of `flake-compat` will cause eval-on-build to be used).

commit61e89b7df59893612fed2ed66cc1405312fde56c authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateWed 7 Jul 2021, 22:43 (5 years ago) parent551407d
5 files changed+21−25
flake.nix+1−4 overlays/default.nix+4−7 overlays/eval-on-build.nix−6 overlays/eval-on-current.nix−8 overlays/eval-packages.nix+16
flake.nix+1−4
@@ -27,10 +27,7 @@
2727 overlaysOverrideable = import ./overlays;
2828 };
2929
30− # Using the eval-on-build version here as the plan is that
31− # `builtins.currentSystem` will not be supported in flakes.
32− # https://github.com/NixOS/rfcs/pull/49/files#diff-a5a138ca225433534de8d260f225fe31R429
33− overlay = self.overlays.combined-eval-on-build;
30+ overlay = self.overlays.combined;
3431 overlays = self.internal.overlaysOverrideable { sourcesOverride = self.internal.sources; };
3532
3633 legacyPackages = let
overlays/default.nix+4−7
@@ -19,8 +19,7 @@ let
1919 nix-prefetch-git-minimal = import ./nix-prefetch-git-minimal.nix;
2020 gobject-introspection = import ./gobject-introspection.nix;
2121 hix = import ./hix.nix;
22− eval-on-current = import ./eval-on-current.nix;
23− eval-on-build = import ./eval-on-build.nix;
22+ eval-packages = import ./eval-packages.nix;
2423 ghcjs = import ./ghcjs.nix;
2524 };
2625
@@ -54,11 +53,9 @@ let
5453 ghcjs
5554 gobject-introspection
5655 hix
56+ eval-packages
5757 # Restore nixpkgs haskell and haskellPackages
5858 (_: prev: { inherit (prev.haskell-nix-prev) haskell haskellPackages; })
5959 ];
60− combined = builtins.foldl' composeExtensions (_: _: { })
61− (ordered ++ [overlays.eval-on-current]);
62− combined-eval-on-build = builtins.foldl' composeExtensions (_: _: { })
63− (ordered ++ [overlays.eval-on-build]);
64−in overlays // { inherit combined combined-eval-on-build; }
60+ combined = builtins.foldl' composeExtensions (_: _: { }) ordered;
61+in overlays // { inherit combined; }
overlays/eval-on-build.nixdeleted−6
@@ -1,6 +0,0 @@
1−final: prev: {
2− # This overlay sets `evalPackages` as just `buildPackages`
3− # See `eval-on-current.nix` for alternative that uses
4− # `builtins.currentSystem`.
5− evalPackages = final.buildPackages;
6−}
overlays/eval-on-current.nixdeleted−8
@@ -1,8 +0,0 @@
1−final: prev: {
2− # This overlay makes `evalPackages` is like `buildPackages`, but on
3− # `builtins.currentSystem`.
4− # See `eval-on-build.nix` for alternative that just uses `buildPackages`.
5− evalPackages = (import final.path {
6− inherit (final.haskell-nix) overlays;
7− }).buildPackages;
8−}
overlays/eval-packages.nixnew file+16
@@ -0,0 +1,16 @@
1+final: prev: {
2+ # This overlay makes `evalPackages` is like `buildPackages`, but on
3+ # `builtins.currentSystem` (when not building a nix flake).
4+ # We do not pass the `config` or `overlays` (not in `final.haskell-nix.overlays`).
5+ # This could cause flake and non flake builds to diverge, although only the
6+ # derivations that use `evalPackages` (these should be eval time only derviations
7+ # used to build nix inputs for IFD, the generated nix should match and so derivations
8+ # that depend on the IFD should match).
9+ evalPackages =
10+ # If we are building a flake there will be no currentSystem attribute
11+ if builtins ? currentSystem
12+ then (import final.path {
13+ inherit (final.haskell-nix) overlays;
14+ }).buildPackages
15+ else final.buildPackages;
16+}