forked from obsidiansystems/obelisk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
all-builds.nix
113 lines (101 loc) · 3.45 KB
/
all-builds.nix
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
{ self-args ? {
config.android_sdk.accept_license = true;
iosSdkVersion = "13.2";
}
, local-self ? import ./. self-args
, supportedSystems ? [ builtins.currentSystem ]
}:
let
inherit (local-self.nixpkgs) lib runCommand nix;
cacheBuildSystems = supportedSystems;
obeliskPackagesCommon = [
"obelisk-frontend"
"obelisk-route"
"obelisk-executable-config-lookup"
];
obeliskPackagesBackend = obeliskPackagesCommon ++ [
"obelisk-asset-manifest"
"obelisk-asset-serve-snap"
"obelisk-backend"
"obelisk-cliapp"
"obelisk-command"
"obelisk-executable-config-inject"
"obelisk-frontend"
"obelisk-run"
"obelisk-route"
"obelisk-selftest"
"obelisk-snap-extras"
];
pnameToAttrs = pkgsSet: pnames:
lib.listToAttrs (map
(name: { inherit name; value = pkgsSet.${name}; })
pnames);
collect = v:
if lib.isDerivation v then [v]
else if lib.isAttrs v then lib.concatMap collect (builtins.attrValues v)
else if lib.isList v then lib.concatMap collect v
else [];
perPlatform = lib.genAttrs cacheBuildSystems (system: let
reflex-platform = import ./dep/reflex-platform { inherit system; };
mkPerProfiling = profiling: let
obelisk = import ./. (self-args // { inherit system profiling; });
ghc = pnameToAttrs
obelisk.haskellPackageSets.ghc
obeliskPackagesBackend;
ghcjs = pnameToAttrs
obelisk.haskellPackageSets.ghcjs
obeliskPackagesCommon;
command = obelisk.command;
withSkeletonOptions = skel: options: (skel.passthru.__unstable__.self.extend (self: super: {
userSettings = super.userSettings // options;
})).project;
rawSkeleton = import ./skeleton { inherit obelisk; };
skeleton = withSkeletonOptions rawSkeleton {
withHoogle = true; # cache the Hoogle database for the skeleton
__withGhcide = true; # cache the ghcide build for the skeleton
};
serverSkeletonExe = rawSkeleton.exe;
# TODO fix nixpkgs so it doesn't try to run the result of haskell shells as setup hooks.
serverSkeletonShell = local-self.nixpkgs.runCommand "shell-safe-for-dep" {} ''
touch "$out"
echo "return" >> "$out"
cat "${skeleton.shells.ghc}" >> "$out"
'';
androidSkeleton = skeleton.android.frontend;
iosSkeleton = skeleton.ios.frontend;
nameSuffix = if profiling then "profiled" else "unprofiled";
packages = {
skeletonProfiledObRun = rawSkeleton.__unstable__.profiledObRun;
inherit
command
serverSkeletonShell
ghc
;
} // lib.optionalAttrs (!profiling) {
inherit
ghcjs
serverSkeletonExe
;
} // lib.optionalAttrs reflex-platform.androidSupport {
inherit androidSkeleton;
} // lib.optionalAttrs reflex-platform.iosSupport {
inherit iosSkeleton;
};
in packages // {
cache = reflex-platform.pinBuildInputs
"obelisk-${system}-${nameSuffix}"
(collect packages);
};
perProfiling = {
profiled = mkPerProfiling true;
unprofiled = mkPerProfiling false;
};
in perProfiling // {
cache = reflex-platform.pinBuildInputs
"obelisk-${system}"
(map (p: p.cache) (builtins.attrValues perProfiling));
});
metaCache = local-self.reflex-platform.pinBuildInputs
"obelisk-everywhere"
(map (a: a.cache) (builtins.attrValues perPlatform));
in perPlatform // { inherit metaCache; }