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