on 19052d8 help sign in
haskell.nix/flake.nix
133 lines 4.6 kB history raw
1{
2 description = "Alternative Haskell Infrastructure for Nixpkgs";
4 inputs = {
5 nixpkgs.follows = "nixpkgs-2105";
6 nixpkgs-2003 = { url = "github:NixOS/nixpkgs/nixpkgs-20.03-darwin"; };
7 nixpkgs-2009 = { url = "github:NixOS/nixpkgs/nixpkgs-20.09-darwin"; };
8 nixpkgs-2105 = { url = "github:NixOS/nixpkgs/nixpkgs-21.05-darwin"; };
9 nixpkgs-unstable = { url = "github:NixOS/nixpkgs/nixpkgs-unstable"; };
10 flake-utils = { url = "github:numtide/flake-utils"; };
11 hackage = {
12 url = "github:input-output-hk/hackage.nix";
13 flake = false;
14 };
15 stackage = {
16 url = "github:input-output-hk/stackage.nix";
17 flake = false;
18 };
19 cabal-32 = {
20 url = "github:haskell/cabal/3.2";
21 flake = false;
22 };
23 cabal-34 = {
24 url = "github:haskell/cabal/3.4";
25 flake = false;
26 };
27 cardano-shell = {
28 url = "github:input-output-hk/cardano-shell";
29 flake = false;
30 };
31 "ghc-8.6.5-iohk" = {
32 type = "github";
33 owner = "input-output-hk";
34 repo = "ghc";
35 ref = "release/8.6.5-iohk";
36 flake = false;
37 };
38 hpc-coveralls = {
39 url = "github:sevanspowell/hpc-coveralls";
40 flake = false;
41 };
42 nix-tools = {
43 url = "github:input-output-hk/nix-tools";
44 flake = false;
45 };
46 old-ghc-nix = {
47 url = "github:angerman/old-ghc-nix/master";
48 flake = false;
49 };
50 HTTP = {
51 url = "github:phadej/HTTP";
52 flake = false;
53 };
54 };
56 outputs = { self, nixpkgs, nixpkgs-unstable, flake-utils, ... }@inputs:
57 let compiler = "ghc884";
58 config = import ./config.nix;
59 in {
60 inherit config;
61 overlay = self.overlays.combined;
62 overlays = import ./overlays { sources = inputs; };
63 internal = rec {
64 nixpkgsArgs = {
65 inherit config;
66 overlays = [ self.overlay ];
67 };
69 sources = inputs;
71 overlaysOverrideable = import ./overlays;
72 # Compatibility with old default.nix
73 compat = { checkMaterialization ?
74 false # Allows us to easily switch on materialization checking
75 , system, sourcesOverride ? { }, ... }@args: rec {
76 sources = inputs // sourcesOverride;
77 allOverlays = import ./overlays (args // { inherit sources; });
78 inherit config;
79 # We are overriding 'overlays' and 'nixpkgsArgs' from the
80 # flake outputs so that we can incorporate the args passed
81 # to the compat layer (e.g. sourcesOverride).
82 overlays = [ allOverlays.combined ]
83 ++ (if checkMaterialization == true then
84 [
85 (final: prev: {
86 haskell-nix = prev.haskell-nix // {
87 checkMaterialization = true;
88 };
89 })
90 ]
91 else
92 [ ]);
93 nixpkgsArgs = {
94 inherit config overlays;
95 };
96 pkgs = import nixpkgs
97 (nixpkgsArgs // { localSystem = { inherit system; }; });
98 pkgs-unstable = import nixpkgs-unstable
99 (nixpkgsArgs // { localSystem = { inherit system; }; });
100 hix = import ./hix/default.nix { inherit pkgs; };
101 };
102 };
104 # Note: `nix flake check` evaluates outputs for all platforms, and haskell.nix
105 # uses IFD heavily, you have to have the ability to build for all platforms
106 # supported by haskell.nix, e.g. with remote builders, in order to check this flake.
107 # If you want to run the tests for just your platform, run `./test/tests.sh` or
108 # `nix-build -A checks.$PLATFORM`
109 } // flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" ] (system: {
110 legacyPackages = (self.internal.compat { inherit system; }).pkgs;
112 # FIXME: Currently `nix flake check` requires `--impure` because coverage-golden
113 # (and maybe other tests) import projects that use builtins.currentSystem
114 checks = builtins.listToAttrs (map (pkg: {
115 name = pkg.name;
116 value = pkg;
117 }) (nixpkgs.lib.collect nixpkgs.lib.isDerivation (import ./test rec {
118 haskellNix = self.internal.compat { inherit system; };
119 compiler-nix-name = compiler;
120 pkgs = haskellNix.pkgs;
121 })));
123 devShell = with self.legacyPackages.${system};
124 mkShell {
125 buildInputs = [
126 nixUnstable
127 cabal-install
128 haskell-nix.compiler.${compiler}
129 haskell-nix.nix-tools.${compiler}
130 ];
131 };
132 });