on iko/ghcjs-patch-master help sign in
flake: export internal functions for more flexibility (#1017)
fd44431Alexander Bantyev
@@ -1,27 +1,34 @@
1{
1{
2 description = "Alternative Haskell Infrastructure for Nixpkgs";
2 description = "Alternative Haskell Infrastructure for Nixpkgs";
3
3
4− outputs = { self }: let
4+ outputs = { self }:
5− config = import ./config.nix;
5+ {
6− # We can't import ./nix/sources.nix directly, because that uses nixpkgs to fetch by default,
7− # and importing nixpkgs without specifying localSystem doesn't work on flakes.
8− sources = let
9− sourcesInfo =
10− builtins.fromJSON (builtins.readFile ./nix/sources.json);
11− fetch = sourceInfo:
12− builtins.fetchTarball { inherit (sourceInfo) url sha256; };
13− in builtins.mapAttrs (_: fetch) sourcesInfo;
14
6
7+ internal = rec {
8+ config = import ./config.nix;
9+ # We can't import ./nix/sources.nix directly, because that uses nixpkgs to fetch by default,
10+ # and importing nixpkgs without specifying localSystem doesn't work on flakes.
11+ sources = let
12+ sourcesInfo =
13+ builtins.fromJSON (builtins.readFile ./nix/sources.json);
14+ fetch = sourceInfo:
15+ builtins.fetchTarball { inherit (sourceInfo) url sha256; };
16+ in builtins.mapAttrs (_: fetch) sourcesInfo;
17+
15− nixpkgsArgs = {
18+ nixpkgsArgs = {
16− inherit config;
19+ inherit config;
17− overlays = [ self.overlay ];
20+ overlays = [ self.overlay ];
21+ };
22+
23+ overlaysOverrideable = import ./overlays;
18 };
24 };
19− in {
25+
20 # Using the eval-on-build version here as the plan is that
26 # Using the eval-on-build version here as the plan is that
21 # `builtins.currentSystem` will not be supported in flakes.
27 # `builtins.currentSystem` will not be supported in flakes.
22 # https://github.com/NixOS/rfcs/pull/49/files#diff-a5a138ca225433534de8d260f225fe31R429
28 # https://github.com/NixOS/rfcs/pull/49/files#diff-a5a138ca225433534de8d260f225fe31R429
23 overlay = self.overlays.combined-eval-on-build;
29 overlay = self.overlays.combined-eval-on-build;
24− overlays = import ./overlays { sourcesOverride = sources; };
30+ overlays = self.internal.overlaysOverrideable { sourcesOverride = self.sources; };
31+
25 legacyPackages = let
32 legacyPackages = let
26 genAttrs = lst: f:
33 genAttrs = lst: f:
27 builtins.listToAttrs (map (name: {
34 builtins.listToAttrs (map (name: {
@@ -29,7 +36,7 @@
29 value = f name;
36 value = f name;
30 }) lst);
37 }) lst);
31 in genAttrs [ "x86_64-linux" "x86_64-darwin" ] (system:
38 in genAttrs [ "x86_64-linux" "x86_64-darwin" ] (system:
32− import sources.nixpkgs
39+ import self.internal.sources.nixpkgs
33− (nixpkgsArgs // { localSystem = { inherit system; }; }));
40+ (self.internal.nixpkgsArgs // { localSystem = { inherit system; }; }));
34 };
41 };
35}
42}