forked from reflex-frp/reflex-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault.nix
More file actions
139 lines (129 loc) · 4.46 KB
/
default.nix
File metadata and controls
139 lines (129 loc) · 4.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
this:
let
inherit (this) nixpkgs;
inherit (nixpkgs.lib) makeExtensible mapAttrs;
in
# This function simplifies the definition of Haskell projects that
# have multiple packages. It provides shells for incrementally working
# on all your packages at once using `cabal.project` files, using any
# version of GHC provided by `reflex-platform`, including GHCJS. It
# also produces individual derivations for each package, which can
# ease devops or integration with other Nix setups.
#
# Example:
#
# > default.nix
#
# (import ./reflex-platform {}).project ({ pkgs, ... }: {
# packages = {
# common = ./common;
# backend = ./backend;
# frontend = ./frontend;
# };
#
# shells = {
# ghc = ["common" "backend" "frontend"];
# ghcjs = ["common" "frontend"];
# };
#
# android.frontend = {
# executableName = "frontend";
# applicationId = "org.example.frontend";
# displayName = "Example App";
# };
# })
#
# > example commands
#
# $ nix-build -A ghc.backend
# $ nix-build -A ghcjs.frontend
# $ nix-build -A android.frontend
# $ nix-shell -A shells.ghc
# $ nix-shell -A shells.ghcjs
#
{ packages
# :: { <package name> :: Path }
#
# An attribute set of local packages being developed. Keys are the
# cabal package name and values are the path to the source
# directory.
, shells ? {}
# :: { <platform name> :: [PackageName] }
#
# The `shells` field defines which platforms we'd like to develop
# for, and which packages' dependencies we want available in the
# development sandbox for that platform. Note in the example above
# that specifying `common` is important; otherwise it will be
# treated as a dependency that needs to be built by Nix for the
# sandbox. You can use these shells with `cabal.project` files to
# build all three packages in a shared incremental environment, for
# both GHC and GHCJS.
, overrides ? _: _: {}
# :: PackageSet -> PackageSet -> { <package name> :: Derivation }
#
# A function for overriding Haskell packages. You can use
# `callHackage` and `callCabal2nix` to bump package versions or
# build them from GitHub. e.g.
#
# overrides = self: super: {
# lens = self.callHackage "lens" "4.15.4" {};
# free = self.callCabal2nix "free" (pkgs.fetchFromGitHub {
# owner = "ekmett";
# repo = "free";
# rev = "a0c5bef18b9609377f20ac6a153a20b7b94578c9";
# sha256 = "0vh3hj5rj98d448l647jc6b6q1km4nd4k01s9rajgkc2igigfp6s";
# }) {};
# }
, android ? throw "No Android config"
# ::
# { <app name> ::
# { executableName :: String
# , applicationId :: String
# , displayName :: String
# , package :: PackageSet -> Derivation
# ^ Optional
# }
# }
#
# Use this argument to configure android apps. The returned
# derivations will be in `android.<app name>`. The `package`
# argument can be set to use a different Haskell package than the
# one named <app name>.
, ios ? throw "No iOS config"
# ::
# { <app name> ::
# { executableName :: String
# , bundleIdentifier :: String
# , bundleName :: String
# , package :: PackageSet -> Derivation
# ^ Optional
# }
# }
#
# Use this argument to configure iOS apps. The returned derivations
# will be in `ios.<app name>`. The `package` argument can be set to
# use a different Haskell package than the one named <app name>.
}:
let
overrides' = nixpkgs.lib.composeExtensions overrides
(self: super: mapAttrs (name: path: self.callCabal2nix name path {}) packages);
mkPkgSet = name: _: this.${name}.override { overrides = overrides'; };
in makeExtensible (prj: mapAttrs mkPkgSet shells // {
shells = mapAttrs (name: pnames:
this.workOnMulti (prj.${name}.override { overrides = self: super: {
ghcWithPackages = self.ghcWithHoogle;
}; }) pnames) shells;
android = mapAttrs (name: config:
let
ghcAndroidArm64 = this.ghcAndroidArm64.override { overrides = overrides'; };
ghcAndroidArmv7a = this.ghcAndroidArmv7a.override { overrides = overrides'; };
in (this.androidWithHaskellPackages { inherit ghcAndroidArm64 ghcAndroidArmv7a; }).buildApp
({ package = p: p.${name}; } // config)
) android;
ios = mapAttrs (name: config:
let ghcIosArm64 = this.ghcIosArm64.override { overrides = overrides'; };
in (this.iosWithHaskellPackages ghcIosArm64).buildApp
({ package = p: p.${name}; } // config)
) ios;
reflex = this;
})