Skip to content

Commit 27f49a1

Browse files
committed
build: improvements (js, static, notebook)
1 parent b84f32e commit 27f49a1

File tree

6 files changed

+168
-49
lines changed

6 files changed

+168
-49
lines changed

build/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ build:
44
nix-build ${NIX_FLAGS}
55

66
build-js:
7-
nix-build ${NIX_FLAGS} --arg compiler \"ghcjs\"
7+
nix-build ${NIX_FLAGS} nodejs.nix
8+
9+
build-static:
10+
nix-build ${NIX_FLAGS} static.nix --show-trace
811

912
shell:
1013
nix-shell ${NIX_FLAGS}

build/default.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{ nixpkgs ? import <nixpkgs> { config.allowBroken = true; }
2-
, compiler ? "ghc844"
2+
, compiler ? "ghc864"
33
}:
44
with nixpkgs;
55
let
6-
haskellPackages = import ./haskell.nix { inherit nixpkgs compiler; };
6+
haskell = import ./haskell.nix { inherit nixpkgs compiler; };
7+
haskellPackages = haskell.packages;
78

89
haskellEnv = haskellPackages.ghcWithPackages (ps: with ps; [
910
language-powerquery-ast
1011
language-powerquery
1112
pbix
12-
m2wasm
1313
]);
1414

1515
in
1616
stdenv.mkDerivation rec {
17-
name = "powerquery-env";
17+
name = "language-powerquery-env";
1818

1919
env = buildEnv { name = name; paths = buildInputs; };
2020
builder = builtins.toFile "builder.sh" ''

build/haskell.nix

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,31 @@
11
{ nixpkgs ? import <nixpkgs> { config.allowBroken = true; }
2-
, compiler ? "ghc844"
2+
, compiler ? "ghc864"
33
, haskellPackages ? nixpkgs.haskell.packages.${compiler}
44
}:
55
with nixpkgs;
6-
let
7-
isGHCJS = lib.hasPrefix "ghcjs" compiler;
8-
ease = package: haskell.lib.doJailbreak (haskell.lib.dontHaddock (haskell.lib.dontCheck package));
9-
10-
#----
11-
fixesGHCJS = hspkgs: if isGHCJS then {
12-
lens = ease hspkgs.lens;
13-
comonad = ease hspkgs.comonad;
14-
semigroupoids = ease hspkgs.semigroupoids;
15-
QuickCheck = ease hspkgs.QuickCheck;
16-
tasty-quickcheck = ease hspkgs.tasty-quickcheck;
17-
scientific = ease hspkgs.scientific;
18-
temporary = ease hspkgs.temporary;
19-
} else {};
20-
21-
#----
22-
languagePowerQueryASTSrc = ../language-powerquery-ast;
23-
languagePowerQuerySrc = ../language-powerquery;
24-
pbixSrc = ../pbix;
25-
m2wasmSrc = ../m2wasm;
6+
rec {
7+
ease = package: with haskell.lib;
8+
( doJailbreak
9+
( dontHaddock
10+
( dontCheck
11+
( package
12+
))));
13+
languagePowerQueryASTSrc = ../language-powerquery-ast;
14+
languagePowerQuerySrc = ../language-powerquery;
15+
languagePowerQueryEditorSrc = ../language-powerquery-editor;
16+
pbixSrc = ../pbix;
2617

2718
projectPackages = hspkgs: {
28-
system-fileio = ease hspkgs.system-fileio;
29-
wasm = ease hspkgs.wasm;
30-
language-powerquery-ast = hspkgs.callCabal2nix "language-powerquery-ast" "${languagePowerQueryASTSrc}" {};
31-
language-powerquery = hspkgs.callCabal2nix "language-powerquery" "${languagePowerQuerySrc}" {};
32-
pbix = hspkgs.callCabal2nix "pbix" "${pbixSrc}" {};
33-
m2wasm = hspkgs.callCabal2nix "m2wasm" "${m2wasmSrc}" {};
19+
language-powerquery-ast = hspkgs.callCabal2nix "language-powerquery-ast" "${languagePowerQueryASTSrc}" {};
20+
language-powerquery = hspkgs.callCabal2nix "language-powerquery" "${languagePowerQuerySrc}" {};
21+
language-powerquery-editor = hspkgs.callCabal2nix "language-powerquery-editor" "${languagePowerQueryEditorSrc}" {};
22+
pbix = hspkgs.callCabal2nix "pbix" "${pbixSrc}" {};
3423
};
35-
in
36-
haskellPackages.override (old: {
37-
overrides = pkgs.lib.composeExtensions old.overrides
38-
(self: hspkgs:
39-
fixesGHCJS hspkgs
40-
// projectPackages hspkgs
41-
);
42-
})
24+
25+
packages = haskellPackages.override (old: {
26+
overrides = pkgs.lib.composeExtensions old.overrides
27+
(self: hspkgs:
28+
projectPackages hspkgs
29+
);
30+
});
31+
}

build/nodejs.nix

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{ nixpkgs ? import <nixpkgs> { config.allowBroken = true; }
2+
, compiler ? "ghcjs"
3+
}:
4+
with nixpkgs;
5+
let
6+
haskell = import ./haskell.nix { inherit nixpkgs compiler; };
7+
ease = haskell.ease;
8+
haskellPackages' = haskell.packages;
9+
10+
haskellPackages = haskellPackages'.override (old: {
11+
overrides = pkgs.lib.composeExtensions old.overrides
12+
(self: hspkgs: {
13+
comonad = ease hspkgs.comonad;
14+
lens = ease hspkgs.lens;
15+
semigroupoids = ease hspkgs.semigroupoids;
16+
QuickCheck = ease hspkgs.QuickCheck;
17+
tasty-quickcheck = ease hspkgs.tasty-quickcheck;
18+
scientific = ease hspkgs.scientific;
19+
temporary = ease hspkgs.temporary;
20+
});
21+
});
22+
23+
haskellEnv = haskellPackages.ghcWithPackages (ps: with ps; [
24+
language-powerquery-ast
25+
language-powerquery
26+
pbix
27+
]);
28+
29+
in
30+
stdenv.mkDerivation rec {
31+
name = "language-powerquery-js-env";
32+
33+
env = buildEnv { name = name; paths = buildInputs; };
34+
builder = builtins.toFile "builder.sh" ''
35+
source $stdenv/setup; ln -s $env $out
36+
'';
37+
38+
buildInputs = [
39+
haskellEnv
40+
];
41+
}

build/notebook.nix

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,41 @@
11
{ nixpkgs ? import <nixpkgs> { config.allowBroken = true; }
2-
, compiler ? "ghc844"
2+
, compiler ? "ghc864"
33
}:
44
with nixpkgs;
55
let
66
jupyterWith = builtins.fetchGit {
77
url = https://github.com/tweag/jupyterWith;
8-
rev = "1176b9e8d173f2d2789705ad55c7b53a06155e0f";
8+
rev = "097591d0949ebf3645d258c5b1c03dcc59a7afcf";
99
};
1010
nixpkgsPath = jupyterWith + "/nix";
1111
pkgs = import nixpkgsPath {};
1212

13-
haskellPackages = import ./haskell.nix
14-
{ nixpkgs = pkgs;
15-
haskellPackages = pkgs.haskellPackages;
16-
};
13+
haskell = import ./haskell.nix
14+
{ nixpkgs = pkgs;
15+
inherit compiler;
16+
haskellPackages = pkgs.haskellPackages;
17+
};
18+
haskellPackages' = haskell.packages;
19+
ease = haskell.ease;
20+
21+
haskellPackages = haskellPackages'.override (old: {
22+
overrides = pkgs.lib.composeExtensions old.overrides
23+
(self: hspkgs: {
24+
});
25+
});
1726

1827
jupyter = import jupyterWith { pkgs=pkgs; };
1928

2029
ihaskellWithPackages = jupyter.kernels.iHaskellWith {
2130
#extraIHaskellFlags = "--debug";
2231
haskellPackages=haskellPackages;
23-
name = "powerquery-env-ihaskell";
32+
name = "platform-env-ihaskell";
2433
packages = p: with p; [
25-
uniplate
34+
lens
2635
lens-aeson
2736
language-powerquery-ast
2837
language-powerquery
2938
pbix
30-
m2wasm
3139
];
3240
};
3341

build/static.nix

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{ nixpkgs ? import <nixpkgs> { config.allowBroken = true; }
2+
, compiler ? "ghc864"
3+
}:
4+
let
5+
happySrc = fetchGit {
6+
url = https://github.com/simonmar/happy;
7+
rev = "27596ff0ce0171d485bf96d38943ffc760923c90";
8+
};
9+
10+
cabal2nixOverlay = self: super:
11+
{ buildPackages = super.buildPackages // {
12+
cabal2nix = super.haskellPackages.cabal2nix;
13+
happy = super.haskellPackages.callCabal2nix "happy" "${happySrc}" {};
14+
};
15+
};
16+
17+
staticHaskellNixpkgsSrc = fetchTarball https://github.com/nh2/nixpkgs/archive/d9cc01374235745ea8581174c4335ae9dda86504.tar.gz;
18+
pkgs = (import staticHaskellNixpkgsSrc { config.allowBroken = true; }).pkgsMusl.appendOverlays [cabal2nixOverlay];
19+
20+
staticHaskellNixSrc = fetchGit {
21+
url = https://github.com/nh2/static-haskell-nix;
22+
rev = "b66fee31b10663588cc23dc806a75f393749d30d";
23+
};
24+
25+
surveyPath = staticHaskellNixSrc + "/survey/default.nix";
26+
survey = ((import surveyPath) { normalPkgs = pkgs;
27+
approach = "pkgsMusl";
28+
integer-simple = true;
29+
}
30+
);
31+
32+
33+
haskell = import ./haskell.nix { inherit compiler;
34+
nixpkgs = pkgs;
35+
haskellPackages = survey.haskellPackages;
36+
};
37+
ease = haskell.ease;
38+
haskellPackages' = haskell.packages;
39+
40+
41+
haskellPackages = haskellPackages'.override (old: {
42+
overrides = pkgs.lib.composeExtensions old.overrides
43+
(self: hspkgs: {
44+
#happy = hspkgs.callCabal2nix "happy" "${happySrc}" {};
45+
});
46+
});
47+
48+
buildStatic = drv: with pkgs.haskell.lib;
49+
( disableSharedExecutables
50+
( disableSharedLibraries
51+
( nixpkgs.lib.flip appendConfigureFlags
52+
[ "--ghc-option=-optl=-static"
53+
"--extra-lib-dirs=${pkgs.gmp6.override { withStatic = true; }}/lib"
54+
"--extra-lib-dirs=${pkgs.zlib.static}/lib"
55+
"--extra-lib-dirs=${pkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib"
56+
]
57+
( drv
58+
))));
59+
60+
haskellEnv = haskellPackages.ghcWithPackages (ps: with ps; [
61+
(buildStatic language-powerquery-ast)
62+
(buildStatic language-powerquery)
63+
(buildStatic pbix)
64+
]);
65+
66+
in
67+
pkgs.stdenv.mkDerivation rec {
68+
name = "language-powerquery-static-env";
69+
70+
env = pkgs.buildEnv { name = name; paths = buildInputs; };
71+
builder = builtins.toFile "builder.sh" ''
72+
source $stdenv/setup; ln -s $env $out
73+
'';
74+
75+
buildInputs = [
76+
haskellEnv
77+
];
78+
}

0 commit comments

Comments
 (0)