Skip to content

Commit

Permalink
flake.nix: Pass haskellNix and isInFlake
Browse files Browse the repository at this point in the history
Refactor flake.nix to pass `haskellNix` and `isInFlake` to
`default.nix` and drop haskellNix.config

* Depending on the value of `isInFlake`, nix/default.nix picks either
haskellNix.overlay or haskellNix.overlays.
* Drop haskellNix.config which doesn't seem relevant for plutus (plutus
doesn't target windows and doesn't use nixpkgs-20.03)
  • Loading branch information
gilligan committed Jun 8, 2021
1 parent d1f577f commit 3719b43
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
7 changes: 2 additions & 5 deletions default.nix
Expand Up @@ -11,17 +11,14 @@
, config ? { allowUnfreePredicate = (import ./nix/lib/unfree.nix).unfreePredicate; }
, sourcesOverride ? { }
, sources ? import ./nix/sources.nix { inherit system; } // sourcesOverride
, isInFlake ? false
, haskellNix ? import sources."haskell.nix" {
sourcesOverride = {
hackage = sources."hackage.nix";
stackage = sources."stackage.nix";
};
}
# haskell-nix has to be used differently in flakes/no-flakes scenarios:
# - When imported from flakes, 'haskellNix.overlay' needs to be passed here.
# - When imported from default.nix without flakes, default to haskellNix.overlays
, haskellNixOverlays ? haskellNix.overlays
, packages ? import ./nix { inherit system sources crossSystem config sourcesOverride haskellNix haskellNixOverlays checkMaterialization enableHaskellProfiling; }
, packages ? import ./nix { inherit system sources crossSystem config sourcesOverride haskellNix isInFlake checkMaterialization enableHaskellProfiling; }
# An explicit git rev to use, passed when we are in Hydra
# Whether to check that the pinned shas for haskell.nix are correct. We want this to be
# false, generally, since it does more work, but we set it to true in the CI
Expand Down
3 changes: 2 additions & 1 deletion flake.nix
Expand Up @@ -12,7 +12,8 @@
let
topLevel = import ./. {
inherit system;
haskellNixOverlays = [ haskell-nix.overlay ];
isInFlake = true;
haskellNix = haskell-nix;
};

inherit (topLevel) pkgs plutus;
Expand Down
10 changes: 7 additions & 3 deletions nix/default.nix
Expand Up @@ -4,8 +4,8 @@
, overlays ? [ ]
, sourcesOverride ? { }
, sources
, isInFlake
, haskellNix
, haskellNixOverlays
, checkMaterialization ? false
, enableHaskellProfiling ? false
}:
Expand All @@ -18,12 +18,16 @@ let
(import ./overlays/r.nix)
];

# haskell-nix has to be used differently in flakes/no-flakes scenarios:
# - When imported from flakes, 'haskellNix.overlay' needs to be passed here.
# - When imported from default.nix without flakes, default to haskellNix.overlays
haskellNixOverlays = if isInFlake then [ haskellNix.overlay ] else haskellNix.overlays;

extraOverlays = haskellNixOverlays ++ ownOverlays;

pkgs = import sources.nixpkgs {
inherit system crossSystem;
inherit config system crossSystem;
overlays = extraOverlays ++ overlays;
config = haskellNix.config // config;
};

plutus = import ./pkgs { inherit pkgs checkMaterialization enableHaskellProfiling sources; };
Expand Down

0 comments on commit 3719b43

Please sign in to comment.