on master help sign in
More caching

following similar style from reflex-platform

commitd0bec96cfa454a0c29e59a2fb65e391e228d0d99 authorJohn Ericson <John.Ericson@Obsidian.Systems> dateThu 11 Oct 2018, 16:17 (8 years ago) parente59cdba
2 files changed+79−43
default.nix+1−1 release.nix+78−42
default.nix+1−1
@@ -337,6 +337,6 @@ in rec {
337337 obelisk = import (base + "/.obelisk/impl") {};
338338 };
339339 haskellPackageSets = {
340− inherit (reflex-platform) ghc;
340+ inherit (reflex-platform) ghc ghcjs;
341341 };
342342}
release.nix+78−42
@@ -1,45 +1,81 @@
11{ local-self ? import ./. {}
2−, local-pkgs ? local-self.nixpkgs
32}:
43
5−with local-pkgs.lib;
6−
7−genAttrs [ "x86_64-linux" "x86_64-darwin" ] (system: {
8− inherit (import ./. { inherit system; }) command;
9− built-skeleton = (import ./skeleton { inherit system; }).all;
10− tests = {
11− #TODO: Doesn't work; see discussion in https://www.pivotaltracker.com/story/show/157265140
12− # ob-init = runCommand "ob-init" {
13− # nativeBuildInputs = [
14− # self.command
15− # nix
16− # ];
17− # } ''
18− # # mkdir $out
19− # # cd $out
20− # # ob init --symlink=${self.path}
21− #'';
22−
23− #TODO: Re-enable this
24− #verify-migration = runCommand "verify-migration" {
25− # nativeBuildInputs = [
26− # self.command
27− # nix # obelisk uses `nix-hash`
28− # ];
29− #} ''
30− # set -e
31− # # Fix permissions so `removePathForcibly` works on copied-to-tmp paths
32− # cp -a ${self.pathGit} $TMPDIR/obelisk
33− # cd $TMPDIR/obelisk
34− # chmod -R u+w .
35− #
36− # (set -x;
37− # ob internal hash;
38− # ob internal verify-migration;
39− # )
40− #
41− # mkdir -p $out
42− # touch $out/done
43− #'';
44− };
45−})
4+let
5+ inherit (local-self.nixpkgs) lib runCommand nix;
6+
7+ cacheBuildSystems = [ "x86_64-linux" "x86_64-darwin" ];
8+
9+ obeliskPackagesFrontendOnly = [
10+ "obelisk-frontend"
11+ "obelisk-route"
12+ "obelisk-executable-config"
13+ ];
14+
15+ obeliskPackages = obeliskPackagesFrontendOnly ++ [
16+ "obelisk-asset-manifest"
17+ "obelisk-asset-serve-snap"
18+ "obelisk-backend"
19+ "obelisk-cliapp"
20+ "obelisk-command"
21+ "obelisk-executable-config-inject"
22+ "obelisk-frontend"
23+ "obelisk-run"
24+ "obelisk-route"
25+ "obelisk-selftest"
26+ "obelisk-snap"
27+ "obelisk-snap-extras"
28+ ];
29+
30+ pnameToAttrs = pkgsSet: pnames:
31+ lib.listToAttrs (map
32+ (name: { inherit name; value = pkgsSet.${name}; })
33+ pnames);
34+
35+ concatDepends = let
36+ extractDeps = x: (x.override {
37+ mkDerivation = drv: {
38+ out = builtins.concatLists [
39+ (drv.buildDepends or [])
40+ (drv.libraryHaskellDepends or [])
41+ (drv.executableHaskellDepends or [])
42+ ];
43+ };
44+ }).out;
45+ in pkgAttrs: builtins.concatLists (map extractDeps (builtins.attrValues pkgAttrs));
46+
47+ perPlatform = lib.genAttrs cacheBuildSystems (system: let
48+ obelisk = import ./. { inherit system; };
49+ reflex-platform = obelisk.reflex-platform;
50+ ghc = pnameToAttrs
51+ obelisk.haskellPackageSets.ghc
52+ obeliskPackages;
53+ ghcjs = pnameToAttrs
54+ obelisk.haskellPackageSets.ghcjs
55+ obeliskPackagesFrontendOnly;
56+ cachePackages = builtins.concatLists [
57+ (builtins.attrValues ghc)
58+ (builtins.attrValues ghcjs)
59+ (concatDepends ghc)
60+ (concatDepends ghcjs)
61+ ];
62+ command = local-self.command;
63+ serverExeSkeleton = (import ./skeleton {}).exe;
64+ builtSkeleton = (import ./skeleton {}).all;
65+ in {
66+ inherit
67+ command
68+ ghc ghcjs
69+ serverExeSkeleton builtSkeleton;
70+ cache = reflex-platform.pinBuildInputs
71+ "obelisk-${system}"
72+ cachePackages
73+ [command serverExeSkeleton builtSkeleton];
74+ });
75+
76+ metaCache = local-self.pinBuildInputs
77+ "reflex-platform-everywhere"
78+ (map (a: a.cache) (builtins.attrValues perPlatform))
79+ [];
80+
81+in perPlatform // { inherit metaCache; }