on master help sign in
Merge remote-tracking branch 'origin/develop' into eac@new-thunks
commit6a8bcee1ffcf9d6bacf1efdf54660269540d23ed authorElliot Cameron <eacameron@gmail.com> dateWed 8 Apr 2020, 15:27 (7 years ago) parentd0c117f50b0e58
6 files changed+138−110
default.nix+5−92 haskell-overlays/misc-deps.nix+20 haskell-overlays/obelisk.nix+43 haskell-overlays/tighten-ob-exes.nix+32 lib/executable-config/default.nix+23−18 nixpkgs-overlays/default.nix+15
default.nix+5−92
@@ -11,105 +11,18 @@ let
1111
1212 inherit (import dep/gitignore.nix { inherit (nixpkgs) lib; }) gitignoreSource;
1313
14− cleanSource = src:
15− # WARNING: The order of application here seems to matter a great deal to
16− # how quickly `ghcid` is able to reload changes. As a rule of thumb,
17− # always apply `gitignoreSource` first.
18− # See https://github.com/obsidiansystems/obelisk/pull/666 and related.
19− pkgs.lib.cleanSource (gitignoreSource src);
20−
21− commandRuntimeDeps = pkgs: with pkgs; [
22− coreutils
23− git
24− nix-prefetch-git
25− openssh
26− ];
27−
2814 getReflexPlatform = { system, enableLibraryProfiling ? profiling }: reflex-platform-func {
2915 inherit iosSdkVersion config system enableLibraryProfiling;
3016
3117 nixpkgsOverlays = [
32− (self: super: {
33− obeliskExecutableConfig = import ./lib/executable-config { nixpkgs = pkgs; filterGitSource = cleanSource; };
34− })
18+ (import ./nixpkgs-overlays)
3519 ];
3620
3721 haskellOverlays = [
38−
39− # Fix misc upstream packages
40− (self: super: let
41− pkgs = self.callPackage ({ pkgs }: pkgs) {};
42− haskellLib = pkgs.haskell.lib;
43− in {
44− hnix = haskellLib.dontCheck (haskellLib.doJailbreak (self.callCabal2nix "hnix" (hackGet dep/hnix) {}));
45− hnix-store-core = self.callHackage "hnix-store-core" "0.1.0.0" {};
46−
47− ghcid = self.callCabal2nix "ghcid" (hackGet ./dep/ghcid) {};
48− # Exports more internals
49− snap-core = haskellLib.dontCheck (self.callCabal2nix "snap-core" (hackGet ./dep/snap-core) {});
50− })
51−
22+ (import ./haskell-overlays/misc-deps.nix { inherit hackGet; })
5223 pkgs.obeliskExecutableConfig.haskellOverlay
53−
54− # Add obelisk packages
55− (self: super: let
56− pkgs = self.callPackage ({ pkgs }: pkgs) {};
57− onLinux = pkg: f: if pkgs.stdenv.isLinux then f pkg else pkg;
58− in {
59− shelly = self.callHackage "shelly" "1.9.0" {};
60−
61− obelisk-executable-config-inject = pkgs.obeliskExecutableConfig.platforms.web.inject self;
62−
63− obelisk-asset-manifest = self.callCabal2nix "obelisk-asset-manifest" (cleanSource ./lib/asset/manifest) {};
64− obelisk-asset-serve-snap = self.callCabal2nix "obelisk-asset-serve-snap" (cleanSource ./lib/asset/serve-snap) {};
65− obelisk-backend = self.callCabal2nix "obelisk-backend" (cleanSource ./lib/backend) {};
66− obelisk-cliapp = self.callCabal2nix "obelisk-cliapp" (cleanSource ./lib/cliapp) {};
67− obelisk-command = haskellLib.overrideCabal (self.callCabal2nix "obelisk-command" (cleanSource ./lib/command) {}) {
68− librarySystemDepends = [
69− pkgs.jre
70− pkgs.nix
71− (haskellLib.justStaticExecutables self.ghcid)
72− ];
73− };
74− obelisk-frontend = self.callCabal2nix "obelisk-frontend" (cleanSource ./lib/frontend) {};
75− obelisk-run = onLinux (self.callCabal2nix "obelisk-run" (cleanSource ./lib/run) {}) (pkg:
76− haskellLib.overrideCabal pkg (drv: { librarySystemDepends = [ pkgs.iproute ]; })
77− );
78− obelisk-route = self.callCabal2nix "obelisk-route" (cleanSource ./lib/route) {};
79− obelisk-selftest = haskellLib.overrideCabal (self.callCabal2nix "obelisk-selftest" (cleanSource ./lib/selftest) {}) {
80− librarySystemDepends = [
81− pkgs.cabal-install
82− pkgs.coreutils
83− pkgs.git
84− pkgs.nix
85− pkgs.nix-prefetch-git
86− pkgs.rsync
87− ];
88− };
89− obelisk-snap-extras = self.callCabal2nix "obelisk-snap-extras" (cleanSource ./lib/snap-extras) {};
90− tabulation = self.callCabal2nix "tabulation" (cleanSource ./lib/tabulation) {};
91− })
92−
93− (self: super: let
94− pkgs = self.callPackage ({ pkgs }: pkgs) {};
95− haskellLib = pkgs.haskell.lib;
96− in {
97− # Dynamic linking with split objects dramatically increases startup time (about
98− # 0.5 seconds on a decent machine with SSD), so we do `justStaticExecutables`.
99− obelisk-command = haskellLib.overrideCabal
100− (haskellLib.generateOptparseApplicativeCompletion "ob"
101− (haskellLib.justStaticExecutables super.obelisk-command))
102− (drv: {
103− buildTools = (drv.buildTools or []) ++ [ pkgs.buildPackages.makeWrapper ];
104− postFixup = ''
105− ${drv.postFixup or ""}
106− # Make `ob` reference its runtime dependencies.
107− wrapProgram "$out"/bin/ob --prefix PATH : ${pkgs.lib.makeBinPath (commandRuntimeDeps pkgs)}
108− '';
109− });
110− obelisk-selftest = haskellLib.justStaticExecutables super.obelisk-selftest;
111− })
112−
24+ (import ./haskell-overlays/obelisk.nix)
25+ (import ./haskell-overlays/tighten-ob-exes.nix)
11326 ];
11427 };
11528
@@ -132,7 +45,7 @@ in rec {
13245 obelisk = ghcObelisk;
13346 obeliskEnvs = pkgs.lib.filterAttrs (k: _: pkgs.lib.strings.hasPrefix "obelisk-" k) ghcObeliskEnvs;
13447 command = ghcObelisk.obelisk-command;
135− shell = pinBuildInputs "obelisk-shell" ([command] ++ commandRuntimeDeps pkgs);
48+ shell = pinBuildInputs "obelisk-shell" ([command] ++ command.commandRuntimeDeps);
13649
13750 selftest = pkgs.writeScript "selftest" ''
13851 #!${pkgs.runtimeShell}
haskell-overlays/misc-deps.nixnew file+20
@@ -0,0 +1,20 @@
1+{ hackGet }:
2+
3+# Fix misc upstream packages
4+self: super:
5+
6+let
7+ pkgs = self.callPackage ({ pkgs }: pkgs) {};
8+ haskellLib = pkgs.haskell.lib;
9+in
10+
11+{
12+ hnix = haskellLib.dontCheck (haskellLib.doJailbreak (self.callCabal2nix "hnix" (hackGet ../dep/hnix) {}));
13+ hnix-store-core = self.callHackage "hnix-store-core" "0.1.0.0" {};
14+
15+ ghcid = self.callCabal2nix "ghcid" (hackGet ../dep/ghcid) {};
16+ # Exports more internals
17+ snap-core = haskellLib.dontCheck (self.callCabal2nix "snap-core" (hackGet ../dep/snap-core) {});
18+
19+ shelly = self.callHackage "shelly" "1.9.0" {};
20+}
haskell-overlays/obelisk.nixnew file+43
@@ -0,0 +1,43 @@
1+# Add obelisk packages
2+
3+self: super:
4+
5+let
6+ pkgs = self.callPackage ({ pkgs }: pkgs) {};
7+ inherit (pkgs) obeliskCleanSource;
8+ haskellLib = pkgs.haskell.lib;
9+ onLinux = pkg: f: if pkgs.stdenv.isLinux then f pkg else pkg;
10+in
11+
12+{
13+ obelisk-executable-config-inject = pkgs.obeliskExecutableConfig.platforms.web.inject self;
14+
15+ obelisk-asset-manifest = self.callCabal2nix "obelisk-asset-manifest" (obeliskCleanSource ../lib/asset/manifest) {};
16+ obelisk-asset-serve-snap = self.callCabal2nix "obelisk-asset-serve-snap" (obeliskCleanSource ../lib/asset/serve-snap) {};
17+ obelisk-backend = self.callCabal2nix "obelisk-backend" (obeliskCleanSource ../lib/backend) {};
18+ obelisk-cliapp = self.callCabal2nix "obelisk-cliapp" (obeliskCleanSource ../lib/cliapp) {};
19+ obelisk-command = haskellLib.overrideCabal (self.callCabal2nix "obelisk-command" (obeliskCleanSource ../lib/command) {}) {
20+ librarySystemDepends = [
21+ pkgs.jre
22+ pkgs.nix
23+ (haskellLib.justStaticExecutables self.ghcid)
24+ ];
25+ };
26+ obelisk-frontend = self.callCabal2nix "obelisk-frontend" (obeliskCleanSource ../lib/frontend) {};
27+ obelisk-run = onLinux (self.callCabal2nix "obelisk-run" (obeliskCleanSource ../lib/run) {}) (pkg:
28+ haskellLib.overrideCabal pkg (drv: { librarySystemDepends = [ pkgs.iproute ]; })
29+ );
30+ obelisk-route = self.callCabal2nix "obelisk-route" (obeliskCleanSource ../lib/route) {};
31+ obelisk-selftest = haskellLib.overrideCabal (self.callCabal2nix "obelisk-selftest" (obeliskCleanSource ../lib/selftest) {}) {
32+ librarySystemDepends = [
33+ pkgs.cabal-install
34+ pkgs.coreutils
35+ pkgs.git
36+ pkgs.nix
37+ pkgs.nix-prefetch-git
38+ pkgs.rsync
39+ ];
40+ };
41+ obelisk-snap-extras = self.callCabal2nix "obelisk-snap-extras" (obeliskCleanSource ../lib/snap-extras) {};
42+ tabulation = self.callCabal2nix "tabulation" (obeliskCleanSource ../lib/tabulation) {};
43+}
haskell-overlays/tighten-ob-exes.nixnew file+32
@@ -0,0 +1,32 @@
1+self: super:
2+
3+let
4+ pkgs = self.callPackage ({ pkgs }: pkgs) {};
5+ haskellLib = pkgs.haskell.lib;
6+
7+ commandRuntimeDeps = with pkgs; [
8+ coreutils
9+ git
10+ nix-prefetch-git
11+ openssh
12+ ];
13+in
14+
15+{
16+ # Dynamic linking with split objects dramatically increases startup time (about
17+ # 0.5 seconds on a decent machine with SSD), so we do `justStaticExecutables`.
18+ obelisk-command = haskellLib.overrideCabal
19+ (haskellLib.generateOptparseApplicativeCompletion "ob"
20+ (haskellLib.justStaticExecutables super.obelisk-command))
21+ (drv: {
22+ buildTools = (drv.buildTools or []) ++ [ pkgs.buildPackages.makeWrapper ];
23+ postFixup = ''
24+ ${drv.postFixup or ""}
25+ # Make `ob` reference its runtime dependencies.
26+ wrapProgram "$out"/bin/ob --prefix PATH : ${pkgs.lib.makeBinPath commandRuntimeDeps}
27+ '';
28+ passthru = { inherit commandRuntimeDeps; };
29+ });
30+
31+ obelisk-selftest = haskellLib.justStaticExecutables super.obelisk-selftest;
32+}
lib/executable-config/default.nix+23−18
@@ -2,26 +2,31 @@
22# configuration information into a canonical location. It also provides a haskell
33# package that can be used to retrieve the injected configuration on each supported
44# platform.
5−{ nixpkgs
6−, filterGitSource # TODO define this in obelisk
5+{ lib
6+, runCommand
7+, obeliskCleanSource
78}:
8−let injectConfig = config: assets: nixpkgs.runCommand "inject-config" {} (''
9− set -x
10− mkdir -p $out
11− cp --no-preserve=mode -Lr "${assets}" $out/static
12− chmod +w "$out"
13− '' + nixpkgs.lib.optionalString (!(builtins.isNull config)) ''
14− if ! mkdir $out/config; then
15− 2>&1 echo config directory already exists or could not be created
16− exit 1
17− fi
18− cp -a "${config}"/* "$out/config"
19− find "$out/config" -type f -printf '%P\0' >"$out/config.files"
20− '');
21−in with nixpkgs.haskell.lib; {
9+
10+let
11+ injectConfig = config: assets: runCommand "inject-config" {} (''
12+ set -x
13+ mkdir -p $out
14+ cp --no-preserve=mode -Lr "${assets}" $out/static
15+ chmod +w "$out"
16+ '' + lib.optionalString (!(builtins.isNull config)) ''
17+ if ! mkdir $out/config; then
18+ 2>&1 echo config directory already exists or could not be created
19+ exit 1
20+ fi
21+ cp -a "${config}"/* "$out/config"
22+ '');
23+in
24+
25+{
2226 haskellOverlay = self: super: {
23− obelisk-executable-config-lookup = self.callCabal2nix "obelisk-executable-config-lookup" (filterGitSource ./lookup) {};
27+ obelisk-executable-config-lookup = self.callCabal2nix "obelisk-executable-config-lookup" (obeliskCleanSource ./lookup) {};
2428 };
29+
2530 platforms = {
2631 android = {
2732 # Inject the given config directory into an android assets folder
@@ -32,7 +37,7 @@ in with nixpkgs.haskell.lib; {
3237 inject = injectConfig;
3338 };
3439 web = {
35− inject = self: self.callCabal2nix "obelisk-executable-config-inject" (filterGitSource ./inject) {};
40+ inject = self: self.callCabal2nix "obelisk-executable-config-inject" (obeliskCleanSource ./inject) {};
3641 };
3742 };
3843}
nixpkgs-overlays/default.nixnew file+15
@@ -0,0 +1,15 @@
1+self: super:
2+
3+let
4+ inherit (self) lib;
5+ inherit (import ../dep/gitignore.nix { inherit lib; }) gitignoreSource;
6+in {
7+ obeliskCleanSource = src:
8+ # WARNING: The order of application here seems to matter a great deal to
9+ # how quickly `ghcid` is able to reload changes. As a rule of thumb,
10+ # always apply `gitignoreSource` first.
11+ # See https://github.com/obsidiansystems/obelisk/pull/666 and related.
12+ lib.cleanSource (gitignoreSource src);
13+
14+ obeliskExecutableConfig = self.callPackage ../lib/executable-config {};
15+}