-
Notifications
You must be signed in to change notification settings - Fork 7
/
default.nix
83 lines (80 loc) · 2.64 KB
/
default.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
{ sources ? import ./nix/sources.nix
, haskellNix ? import sources.haskellNix { inherit system; }
, pkgsSrc ? import haskellNix.sources.nixpkgs-2105
, pkgs ? pkgsSrc (haskellNix.nixpkgsArgs // { inherit system; })
, nix-filter ? import sources.nix-filter
, system ? builtins.currentSystem
, prod ? false
}:
let
octopod-css = import ./octopod-css { inherit pkgsSrc; };
insaneOptimizationFlags = [
"-O2"
"-fexpose-all-unfoldings"
"-fspecialise-aggressively"
];
addLocalOptions = x:
if prod then x // {
ghcOptions = [ "-Werror" ] ++ insaneOptimizationFlags;
}
else x // { ghcOptions = [ "-O0" ]; };
hsPkgs = pkgs.haskell-nix.cabalProject {
src = nix-filter {
root = ./.;
name = "octopod";
include = [
./octopod-backend/octopod-backend.cabal
./octo-cli/octo-cli.cabal
./octopod-api/octopod-api.cabal
./octopod-common/octopod-common.cabal
./octopod-frontend/octopod-frontend.cabal
./cabal.project
];
};
modules = [
{
ghcOptions = insaneOptimizationFlags;
dontStrip = false;
dontPatchELF = false;
enableDeadCodeElimination = true;
packages.octopod-backend = addLocalOptions (
if prod
then {
src = pkgs.runCommand "octopod-backend-src" { }
''
mkdir -p $out
cp -r ${./octopod-backend}/* $out
cp -r ${builtins.path { path = ./.git; name = "dot-git"; }}/ $out/.git/
'';
components.exes.octopod-exe = {
build-tools =
pkgs.lib.mkForce [ pkgs.buildPackages.buildPackages.gitReallyMinimal ];
extraSrcFiles = [ ".git/**/*" ];
};
}
else { src = ./octopod-backend; }
);
packages.octo-cli = addLocalOptions { src = ./octo-cli; };
packages.octopod-api = addLocalOptions { src = ./octopod-api; };
packages.octopod-frontend = addLocalOptions { src = ./octopod-frontend; };
packages.octopod-common = addLocalOptions { src = ./octopod-common; };
}
];
index-state = "2021-11-22T00:00:00Z";
compiler-nix-name = "ghc8107";
};
in
hsPkgs // {
octopod-frontend-pretty =
let frontend = hsPkgs.projectCross.ghcjs.hsPkgs.octopod-frontend.components.exes.frontend;
in
pkgs.runCommand "octopod-frontend-pretty"
{ } ''
mkdir $out
cp -av ${octopod-css}/* $out
cp ${./octopod-frontend/index.html} $out/index.html
cp ${frontend}/bin/frontend.jsexe/all.js $out/all.js
cp ${frontend}/bin/frontend.jsexe/all.js.externs $out/all.js.externs
'';
inherit pkgsSrc;
}